Reputation: 5082
steps:
- task: Docker@2
displayName: Build and Push
inputs:
command: buildAndPush
containerRegistry: myAcrServiceConnection
repository: roket
tags: |
02
latest
The above snippet build an image with tag 02 and tag latest from the same source and push it to the azure container registry.
How can I replace the 02 in the tags to an automatic increment style. For example it will fist fetch the remote or local catch and increment 1 to the tag?
Upvotes: 4
Views: 4315
Reputation: 1341
You can define the build number in a way that is going to strictly increment (for instance $(Date:yyyyMMdd)$(Rev:.rr)
), and use $(Build.BuildNumber)
as a tag for the image.
From the official documentation:
Use $(Rev:r) to ensure that every completed build has a unique name. When a build is completed, if nothing else in the build number has changed, the Rev integer value is incremented by one.
Upvotes: 4