This page shows the source for this entry, with WebCore formatting language tags and attributes highlighted.
Title
Set a Git Tag on Azure
Description
As with <a href="{app]view_article.php?id=4223">installing a dotnet tool on Azure</a>, there isn't a standard task for setting a Git tag from a pipeline YAML configuration. The Pipeline UI has an option to easily do this, but that hasn't translated to a task yet, nor does it look like it's likely to, according to online discussions.
Setting a Git tag is relatively straightforward, but is complicated by permissions (as with <a href="{app]view_article.php?id=4223">installing a dotnet tool</a>. To tag a build, you have to just execute the <c>git</c> commands in a script.
<code>
- task: CmdLine@2
displayName: Push Git Tag
inputs:
script: |
git tag $(Build.BuildNumber)
git push origin $(Build.BuildNumber)
</code>
If, for whatever reason, you want the tag to be created by the triggering user, then include the following lines as well:
<code>
- task: CmdLine@2
displayName: Push Git Tag
inputs:
script: |
git config user.email $env:BUILD_REQUESTEDFOREMAIL
git config user.name $env:BUILD_REQUESTEDFOR
git tag $(Build.BuildNumber)
git push origin $(Build.BuildNumber)
</code>
You should include this step after the version number has been updated.
With the task in place, you have to ensure that you've granted permissions to the proper user.
<ol>
Go to the "project settings"
Select "Repos/Repositories"
Select the "Permissions" tab
Allow the specific permission "Contribute" for the "Project Collection Build Service" user.<fn>
</ol>
<img src="{att_link}repositorypermissions.png" href="{att_link}repositorypermissions.png" align="none" caption="Granting Repository Permissions" scale="40%">
<hr>
<ft>Note: granting the permission to "Project Collection Build Service Accounts" or "[Project Name] Build Services" had no noticeable effect.</ft>