How do we add custom annotated tags on master
once the pull requests (PR) is complete, automatically?
More background:
azure-pipelines.yml
master
to force PR to be usedMAJOR
.MINOR
.PATCH
"MAJOR
.MINOR
"MAJOR
"Pin on MAJOR
only example:
resources:
repositories:
- repository: templates
type: git
name: template_devops_pipelines
ref: "refs/tags/v1"
A sample tagging pipeline that I use:
trigger:
- main
variables:
user.email: "[email protected]"
user.name: "DevOps"
defaultBranch: "main"
major: 1
minor: 0
patch: $[counter(variables['patch'], 2)]
name: $(major).$(minor).$(patch)
steps:
- checkout: self
persistCredentials: true
- script: |
git config user.email ${{variables['user.email']}}
git config user.name ${{variables['user.name']}}
displayName: 'configure git credentials'
- script: |
git tag "$(Build.BuildNumber)"
git push origin "$(Build.BuildNumber)"
displayName: 'git tag'
condition: eq(variables['Build.SourceBranchName'], variables['defaultBranch'])
You basically need three things:
persistCredentials
- so your pipeline can tag and push laterFor the last step, you will need to assign "Contribute" permissions to pipeline build service account. Go to: Project Settings -> Repositiories -> {your repo} -> Security
, find user {your organization} Build Service
and set Contribute to Allow
.
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