Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
668 views
in Technique[技术] by (71.8m points)

git - How to trigger VSTS build and release when pushing tags?

I have rather simple scenarion, one master branch then when I want to do a production release I want to tag a commit with eg. vX.X.X.

The CI/CD pipeline looks like this

Build -> Staging Environment -> Production Environment

  1. Every commit to master is sent to staging environment
  2. When I add a vX.X.X tag to a commit I want the staging and production environment to trigger.

I have found this link Trigger build when pushing tag to git. I just can't figure it out how to make it work. It simply does not work for me.

Is it possible and how do I configure the VSTS to start a build when a tag is added to a commit?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

When commit with tag pushed to master branch, build will be triggered for twice (on master branch and the tag) separately, you need to specify the Production Environment triggered after release not after Staging Environment.

And the build and release definitions settings as below:

Build definition:

In Triggers Tab -> set branch filter to include master and refs/tags/v* ->Save.

enter image description here

Release definition:

Specify Artifact filter to include master branch for Staging Environment -> select After release for Production Environment trigger -> specify Artifact filter to include refs/tags/v* for Production Environment -> Save.

enter image description here

enter image description here

If only commits are pushed to master branch -> a build is triggered for master branch -> a new release is created -> only deploy Staging Environment.

If both commits and tags are pushed to master branch -> two builds are triggered (one for master branch, the other for refs/tags/v*) -> two releases are created:

enter image description here

  • For the release linked with build artifacts on master branch -> only Staging Environment is deployed;

    enter image description here

  • For the release linked with build artifacts on refs/tags/v* -> only Product Environment is deployed.

    enter image description here


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...