推送标签时如何触发VSTS构建和发布? [英] How to trigger VSTS build and release when pushing tags?
问题描述
我有一个非常简单的方案,一个主分支,然后当我要进行生产发布时,我想用例如标记提交. vX.X.X.
CI/CD管道如下所示
构建->临时环境->生产环境
- 对母版的每次提交都发送到登台环境
- 当我向提交中添加vX.X.X标签时,我希望触发登台和生产环境.
我已找到此链接解决方案
将带有标签的提交提交到master
分支时,构建将分别触发两次(在主分支和标签上),您需要指定生产环境在发布后触发,而不是在暂存环境后触发.
以及下面的构建和发布定义设置:
内部定义:
在触发器"标签中->将分支过滤器设置为包括master
和refs/tags/v*
->保存.
发布定义:
为暂存环境指定工件过滤器以包含master
分支->为生产环境触发器选择发布后->为生产环境指定工件过滤器以包括refs/tags/v*
->保存.
如果仅将提交推送到master
分支->为master
分支触发构建->创建新版本->仅部署登台环境.
如果将提交和标记都推送到master
分支->会触发两个构建(一个用于master
分支,另一个用于refs/tags/v*
)->创建两个发行版:
-
对于与
master
分支上的构建工件相关联的发行版->仅部署登台环境; -
对于与
refs/tags/v*
->上的构建工件链接的发行版,仅部署产品环境.
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
- Every commit to master is sent to staging environment
- 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?
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.
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.
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:
For the release linked with build artifacts on
master
branch -> only Staging Environment is deployed;For the release linked with build artifacts on
refs/tags/v*
-> only Product Environment is deployed.
这篇关于推送标签时如何触发VSTS构建和发布?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!