Mats Iremark
Mats Iremark

Reputation: 93

Accessing container resource variables in Azure Devops YAML Pipeline

Using Azure Devops YAML Pipelines and trying to have a pipeline trigger on a container being pushed to an ACR.

According to the documentation in the link below, I should be able to access the tag and other information related to the image using variables like RESOURCES_CONTAINER_IDENTIFIER_TAG that should be available.

https://learn.microsoft.com/en-us/azure/devops/pipelines/process/resources?view=azure-devops&tabs=schema

However, I see no trace of variables from Containers or Repositories. It works fine with Pipelines and I haven't tested Builds. To be clear, the pipeline is triggered fine but inside the pipeline I cannot see which tag triggered it.

So is there something special that needs to be done here or is it released in the documentation but not working yet?

Upvotes: 2

Views: 2273

Answers (1)

LoLance
LoLance

Reputation: 28196

Just as the document states:

resources.container.<Alias>.tag is what you want and it should work because this feature is supported since Sprint 159. (Now it's Sprint 164.)

Sample yaml:

resources:
  containers:
  - container: ACRResource1
    type: ACR
    azureSubscription: ARM
    resourceGroup: xxx
    registry: xxx
    repository: xxx/docker-acr:v1-tag
  - container: ACRResource2
    type: ACR
    azureSubscription: ARM
    resourceGroup: xxx
    registry: xxx
    repository: xxx/docker-acr

Sample output:

resources.container.ACRResource1.tag = v1-tag
resources.container.ACRResource2.tag = v10-tag  (latest tag value)

Make sure you configured the yaml and settings well and created valid service connections.

Upvotes: 2

Related Questions