Skip to content

Commit 73da24e

Browse files
edits
1 parent 9cdd4bf commit 73da24e

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

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

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,29 @@ steps:
202202
- build: -t $Registry/hello-world -f hello-world.dockerfile ./subDirectory
203203
```
204204

205+
### Dynamic Variable Passing in ACR Tasks
206+
207+
When working with Azure container registry (ACR) tasks, you may find yourself needing to pass different values to your build process without changing the task definition by using the `--set` flag with the `az acr task run` command.
208+
209+
#### Example: Setting image tag at runtime
210+
211+
Suppose you have an ACR task defined in a `acr-task.yml` file with a placeholder for the image tag:
212+
213+
```yaml
214+
steps:
215+
- build: -t $Registry/hello-world:{{.Values.tag}}
216+
```
217+
218+
You can trigger the task and set the `tag` variable to `v2` at runtime using the following Azure CLI command:
219+
220+
```azurecli
221+
az acr task run --registry myregistry --name mytask --set tag=v2
222+
```
223+
224+
This command will start the ACR task named `mytask` and build the image using the `v2` tag, overriding the placeholder in the `acr-task.yml` file.
225+
226+
This approach allows for customization in your CI/CD pipelines, enabling you to dynamically adjust parameters based on your current needs without altering the task definitions.
227+
205228
## push
206229

207230
Push one or more built or retagged images to a container registry. Supports pushing to private registries like Azure Container Registry, or to the public Docker Hub.
@@ -385,6 +408,7 @@ az acr run -f mounts-secrets.yaml --set-secret mysecret=abcdefg123456 https://gi
385408
<!-- SOURCE: https://github.com/Azure-Samples/acr-tasks/blob/master/mounts-secrets.yaml -->
386409
[!code-yml[task](~/acr-tasks/mounts-secrets.yaml)]
387410

411+
388412
## Task step properties
389413

390414
Each step type supports several properties appropriate for its type. The following table defines all of the available step properties. Not all step types support all properties. To see which of these properties are available for each step type, see the [cmd](#cmd), [build](#build), and [push](#push) step type reference sections.

0 commit comments

Comments
 (0)