You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -193,21 +193,21 @@ Push one or more built or retagged images to a container registry. Supports push
193
193
The `push` step type supports a collection of images. YAML collection syntax supports inline and nested formats. Pushing a single image is typically represented using inline syntax:
For increased readability, use nested syntax when pushing multiple images:
203
203
204
204
```yml
205
-
version: v1.0.0
205
+
version: v1.1.0
206
206
steps:
207
207
# Nested YAML collection syntax
208
208
- push:
209
-
- {{.Run.Registry}}/hello-world:{{.Run.ID}}
210
-
- {{.Run.Registry}}/hello-world:latest
209
+
- $Registry/hello-world:$ID
210
+
- $Registry/hello-world:latest
211
211
```
212
212
213
213
### Properties: push
@@ -250,7 +250,7 @@ The `cmd` step type runs a container.
250
250
### Syntax: cmd
251
251
252
252
```yml
253
-
version: v1.0.0
253
+
version: v1.1.0
254
254
steps:
255
255
- [cmd]: [containerImage]:[tag (optional)] [cmdParameters to the image]
256
256
```
@@ -326,33 +326,31 @@ az acr run -f bash-echo-3.yaml https://github.com/Azure-Samples/acr-tasks.git
326
326
The `cmd` step type references images using the standard `docker run` format. Images not prefaced with a registry are assumed to originate from docker.io. The previous example could equally be represented as:
327
327
328
328
```yml
329
-
version: v1.0.0
329
+
version: v1.1.0
330
330
steps:
331
331
- cmd: docker.io/bash:3.0 echo hello world
332
332
```
333
333
334
334
By using the standard `docker run` image reference convention, `cmd` can run images from any private registry or the public Docker Hub. If you're referencing images in the same registry in which ACR Task is executing, you don't need to specify any registry credentials.
335
335
336
-
* Run an image that's from an Azure container registry
337
-
338
-
Replace `[myregistry]` with the name of your registry:
336
+
* Run an image that's from an Azure container registry. The following example assumes you have a registry named `myregistry`, and a custom image `myimage:mytag`.
339
337
340
338
```yml
341
-
version: v1.0.0
339
+
version: v1.1.0
342
340
steps:
343
-
- cmd: [myregistry].azurecr.io/bash:3.0 echo hello world
341
+
- cmd: myregistry.azurecr.io/myimage:mytag
344
342
```
345
343
346
-
* Generalize the registry reference with a Run variable
344
+
* Generalize the registry reference with a Run variable or alias
347
345
348
-
Instead of hard-coding your registry name in an `acr-task.yaml` file, you can make it more portable by using a [Run variable](#run-variables). The `Run.Registry` variable expands at runtime to the name of the registry in which the task is executing.
346
+
Instead of hard-coding your registry name in an `acr-task.yaml` file, you can make it more portable by using a [Run variable](#run-variables) or [alias](#aliases). The `Run.Registry` variable or `$Registry` alias expands at runtime to the name of the registry in which the task is executing.
349
347
350
-
To generalize the preceding task so that it works in any Azure container registry, reference the [Run.Registry](#runregistry) variable in the image name:
348
+
For example, to generalize the preceding task so that it works in any Azure container registry, reference the $Registry variable in the image name:
351
349
352
350
```yml
353
-
version: v1.0.0
351
+
version: v1.1.0
354
352
steps:
355
-
- cmd: {{.Run.Registry}}/bash:3.0 echo hello world
353
+
- cmd: $Registry/myimage:mytag
356
354
```
357
355
358
356
## Task step properties
@@ -447,31 +445,50 @@ az acr run -f when-parallel-dependent.yaml https://github.com/Azure-Samples/acr-
447
445
ACR Tasks includes a default set of variables that are available to task steps when they execute. These variables can be accessed by using the format `{{.Run.VariableName}}`, where `VariableName` is one of the following:
448
446
449
447
* `Run.ID`
448
+
* `Run.SharedVolume`
450
449
* `Run.Registry`
450
+
* `Run.RegistryName`
451
451
* `Run.Date`
452
+
* `Run.OS`
453
+
* `Run.Architecture`
452
454
* `Run.Commit`
453
455
* `Run.Branch`
456
+
* `Run.TaskName`
457
+
458
+
The variable names are generally self-explanatory. Details follows for commonly used variables. As of YAML version `v1.1.0`, you can use an abbreviated, predefined [task alias](#aliases) in place of most run variables. For example, in place of `{{.Run.Registry}}`, use the `$Registry` alias.
454
459
455
460
### Run.ID
456
461
457
-
Each Run, through `az acr run`, or trigger based execution of tasks created through `az acr task create` have a unique ID. The ID represents the Run currently being executed.
462
+
Each Run, through `az acr run`, or trigger based execution of tasks created through `az acr task create`, has a unique ID. The ID represents the Run currently being executed.
The fully qualified server name of the registry. Typically used to generically reference the registry where the task is being run.
470
475
471
476
```yml
472
-
version: v1.0.0
477
+
version: v1.1.0
478
+
steps:
479
+
- build: -t $Registry/hello-world:$ID .
480
+
```
481
+
482
+
### Run.RegistryName
483
+
484
+
The name of the container registry. Typically used in task steps that don't require a fully qualified server name, for example, `cmd` steps that run Azure CLI commands on registries.
- cmd: az acr repository list --name $RegistryName
475
492
```
476
493
477
494
### Run.Date
@@ -486,12 +503,89 @@ For a task triggered by a commit to a GitHub repository, the commit identifier.
486
503
487
504
For a task triggered by a commit to a GitHub repository, the branch name.
488
505
506
+
## Aliases
507
+
508
+
As of `v1.1.0`, ACR Tasks supports aliases that are available to task steps when they execute. Aliases are similar in concept to aliases (command shortcuts) supported in bash and some other command shells.
509
+
510
+
With an alias, you can launch any command or group of commands (including options and filenames) by entering a single word.
511
+
512
+
ACR Tasks supports several predefined aliases and also custom aliases you create.
513
+
514
+
### Predefined aliases
515
+
516
+
The following task aliases are available to use in place of [run variables](#run-variables):
517
+
518
+
| Alias | Run variable |
519
+
| ----- | ------------ |
520
+
| `ID` | `Run.ID` |
521
+
| `SharedVolume` | `Run.SharedVolume` |
522
+
| `Registry` | `Run.Registry` |
523
+
| `RegistryName` | `Run.RegistryName` |
524
+
| `Date` | `Run.Date` |
525
+
| `OS` | `Run.OS` |
526
+
| `Architecture` | `Run.Architecture` |
527
+
| `Commit` | `Run.Commit` |
528
+
| `Branch` | `Run.Branch` |
529
+
530
+
In task steps, precede an alias with the `$` directive, as in this example:
Each of the following aliases points to a stable image in Microsoft Container Registry (MCR). You can refer to each of them in the `cmd` section of a Task file without using a directive.
The following example task uses several aliases to [purge](container-registry-auto-purge.md) image tags older than 7 days in the repo `samples/hello-world` in the run registry:
550
+
551
+
```yaml
552
+
version: v1.1.0
553
+
steps:
554
+
- cmd: acr tag list --registry $RegistryName --repository samples/hello-world
Define a custom alias in your YAML file and use it as shown in the following example. An alias can contain only alphanumeric characters. The default directive to expand an alias is the `$` character.
0 commit comments