Christophe Blin
Christophe Blin

Reputation: 1909

Automatically add a git tag after a pull request is accepted

We are following the gitflow workflow with support versions and we are also using PR (feature -> develop [squash], hotfix -> support/x.x, hotfix -> develop, release/x.x -> master)

The problem is that pull requests for releases are not strictly equivalent to "git flow release finish", especially because a tag is not added to master (also you need another PR to develop).

The problem is the same for hotfixes (you have 2 PRs to do and support/x.x is not tagged)

One thing that will sove the problem is the ability to add a tag on the destination branch of a PR when the PR is accepted.

Do you know if some automation is possible around that use case ?

Upvotes: 4

Views: 5795

Answers (2)

YoavKlein
YoavKlein

Reputation: 2703

Adding to @LeoLiu-MSFT answer: you can add a "release" pipeline that runs upon pushes to the target branches that runs a script to tag the current commit and push the tag.

Upvotes: 0

Leo Liu
Leo Liu

Reputation: 76760

Automatically add a git tag after a pull request is accepted

I am afraid there is no such way to add a tag on the destination branch of a PR when the PR is accepted.

We could create a scripts to add a git tag automatically, like:

if [ -z "$NEEDS_TAG" ]; then
    echo "Tagged with $NEW_TAG "
    git tag $NEW_TAG
    git push --tags
else
    echo "Already a tag on this commit"
fi

But, we could not execute this scripts after a pull request is accepted. Because there is no such option or hook to trigger this scripts after the pull request is accepted.

Besides, the options for the Branch Policies, like Build validation, are completed before the pull request accepted.

You could add your request for this feature on our UserVoice site (https://developercommunity.visualstudio.com/content/idea/post.html?space=21 ), which is our main forum for product suggestions. Thank you for helping us build a better Azure DevOps.

enter image description here

Hope this helps.

Upvotes: 4

Related Questions