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?
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With