Skip to content

Commit 5d6bfd6

Browse files
committed
Incorp'd review feedback
1 parent 5888732 commit 5d6bfd6

File tree

1 file changed

+20
-22
lines changed

1 file changed

+20
-22
lines changed

articles/container-registry/container-registry-tasks-reference-yaml.md

Lines changed: 20 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ manager: gwallace
77

88
ms.service: container-registry
99
ms.topic: article
10-
ms.date: 10/09/2019
10+
ms.date: 10/23/2019
1111
ms.author: danlep
1212
---
1313

@@ -181,7 +181,7 @@ az acr run -f build-hello-world.yaml https://github.com/AzureCR/acr-tasks-sample
181181
```yml
182182
version: v1.1.0
183183
steps:
184-
- build: -t {{.Run.Registry}}/hello-world -f hello-world.dockerfile ./subDirectory
184+
- build: -t $Registry/hello-world -f hello-world.dockerfile ./subDirectory
185185
```
186186

187187
## push
@@ -196,7 +196,7 @@ The `push` step type supports a collection of images. YAML collection syntax sup
196196
version: v1.1.0
197197
steps:
198198
# Inline YAML collection syntax
199-
- push: ["{{.Run.Registry}}/hello-world:{{.Run.ID}}"]
199+
- push: ["$Registry/hello-world:$ID"]
200200
```
201201

202202
For increased readability, use nested syntax when pushing multiple images:
@@ -206,8 +206,8 @@ version: v1.1.0
206206
steps:
207207
# Nested YAML collection syntax
208208
- push:
209-
- {{.Run.Registry}}/hello-world:{{.Run.ID}}
210-
- {{.Run.Registry}}/hello-world:latest
209+
- $Registry/hello-world:$ID
210+
- $Registry/hello-world:latest
211211
```
212212

213213
### Properties: push
@@ -333,26 +333,24 @@ steps:
333333

334334
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.
335335

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`.
339337

340338
```yml
341339
version: v1.1.0
342340
steps:
343-
- cmd: [myregistry].azurecr.io/bash:3.0 echo hello world
341+
- cmd: myregistry.azurecr.io/myimage:mytag
344342
```
345343

346-
* Generalize the registry reference with a Run variable
344+
* Generalize the registry reference with a Run variable or alias
347345

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.
349347

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:
351349

352350
```yml
353351
version: v1.1.0
354352
steps:
355-
- cmd: {{.Run.Registry}}/bash:3.0 echo hello world
353+
- cmd: $Registry/myimage:mytag
356354
```
357355

358356
## Task step properties
@@ -455,19 +453,20 @@ ACR Tasks includes a default set of variables that are available to task steps w
455453
* `Run.Architecture`
456454
* `Run.Commit`
457455
* `Run.Branch`
456+
* `Run.TaskName`
458457

459-
The variable names are generally self-explanatory. Details follows for commonly used variables.
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.
460459

461460
### Run.ID
462461

463-
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.
464463

465464
Typically used for a uniquely tagging an image:
466465

467466
```yml
468467
version: v1.1.0
469468
steps:
470-
- build: -t {{.Run.Registry}}/hello-world:{{.Run.ID}} .
469+
- build: -t $Registry/hello-world:$ID .
471470
```
472471

473472
### Run.Registry
@@ -477,7 +476,7 @@ The fully qualified server name of the registry. Typically used to generically r
477476
```yml
478477
version: v1.1.0
479478
steps:
480-
- build: -t {{.Run.Registry}}/hello-world:{{.Run.ID}} .
479+
- build: -t $Registry/hello-world:$ID .
481480
```
482481

483482
### Run.RegistryName
@@ -488,8 +487,8 @@ The name of the container registry. Typically used in task steps that don't requ
488487
version 1.1.0
489488
steps:
490489
# List repositories in registry
491-
- cmd: "mcr.microsoft.com/azure-cli az login --identity"
492-
- cmd: "mcr.microsoft.com/azure-cli az acr repository list --name {{.Run.RegistryName}}"
490+
- cmd: az login --identity
491+
- cmd: az acr repository list --name $RegistryName
493492
```
494493

495494
### Run.Date
@@ -514,7 +513,7 @@ ACR Tasks supports several predefined aliases and also custom aliases you create
514513

515514
### Predefined aliases
516515

517-
The following task aliases are available to use in place of run variables:
516+
The following task aliases are available to use in place of [run variables](#run-variables):
518517

519518
| Alias | Run variable |
520519
| ----- | ------------ |
@@ -543,7 +542,6 @@ Each of the following aliases points to a stable image in Microsoft Container Re
543542
| Alias | Image |
544543
| ----- | ----- |
545544
| `acr` | `mcr.microsoft.com/acr/acr-cli:0.1` |
546-
| `purge` | `mcr.microsoft.com/acr/acr-cli:0.1 purge` |
547545
| `az` | `mcr.microsoft.com/acr/azure-cli:d0725bc` |
548546
| `bash` | `mcr.microsoft.com/acr/bash:d0725bc` |
549547
| `curl` | `mcr.microsoft.com/acr/curl:d0725bc` |
@@ -554,7 +552,7 @@ The following example task uses several aliases to [purge](container-registry-au
554552
version: v1.1.0
555553
steps:
556554
- cmd: acr tag list --registry $RegistryName --repository samples/hello-world
557-
- cmd: purge --registry $RegistryName --filter samples/hello-world:.* --ago 7d
555+
- cmd: acr purge --registry $RegistryName --filter samples/hello-world:.* --ago 7d
558556
```
559557

560558
### Custom alias

0 commit comments

Comments
 (0)