1
votes

For several environments, I need to have different docker image tagging policies, that is: dev and release should utilize 'Latest' tag, while production should have proper version tag.

I am currently using single Yaml file for all AzureDevOps Build Pipeline, and want to have image tagging mode to be defined as Variable per build /lets say called $(Versioned)/.

The build step is shown below:

steps
- bash: docker push $(imageFullName):latest
  displayName: 'docker push'

So is there any way to have IF statement or other conditional operation here. For example:

steps
- bash: docker push $(imageFullName):IF($(Versioned), $(Build.BuildNumber), latest)
  displayName: 'docker push'
1

1 Answers

1
votes

you can maybe do this with something like this:

steps
- bash: docker push $(imageFullName):latest
  displayName: 'docker push'
  condition: eq($(Versioned), 'true')
- bash: docker push $(imageFullName):$(Build.BuildNumber)
  displayName: 'docker push'
  condition: ne($(Versioned), 'true')