[英]How to stop azure-devops release-pipeline from failing
I have a release-pipeline that deploys builds.我有一个部署构建的发布管道。 It's set to run after the build finishes.
它设置为在构建完成后运行。 Builds have a BuildNumber that includes the product version number.
构建具有包含产品版本号的 BuildNumber。 I want to only deploy zero builds that have a version number ending with .0
我只想部署版本号以 .0 结尾的零构建
I tried adding a Stage with a Powershell task that checks the version number and fails if it's not a zero build.我尝试添加一个带有 Powershell 任务的 Stage,该任务检查版本号,如果它不是零构建则失败。 I also tried to add a gate to the deployment stage that also checks the version number.
我还尝试在部署阶段添加一个检查版本号的门。
Both of these ways of checking result in the release-pipeline failing, and I get an email telling me it's failed.这两种检查方式都会导致发布管道失败,我收到一封电子邮件,告诉我它失败了。
How can I make the release-pipeline succeed, but do nothing for non-zero builds?如何使发布管道成功,但对非零构建不执行任何操作?
The powershell was:电源外壳是:
if ( "$(Release.Artifacts._TheBuild.BuildNumber)" -like ".0 " )
{
exit 0
}
else
{
exit 1
}
The gate calls out to an azure function and passes $(Release.Artifacts._TheBuild.BuildNumber) as an argument.门调用 azure 函数并将 $(Release.Artifacts._TheBuild.BuildNumber) 作为参数传递。 The azure function returns json with a status of true or false depending on whether the version number ends with zero.
azure 函数返回状态为真或假的 json,具体取决于版本号是否以零结尾。 The gate evaluates this immediately, has the minimum retry and timeout of 5 and 6 minutes respectively.
门立即对此进行评估,最小重试和超时分别为 5 分钟和 6 分钟。
This can be done via Custom Condition
under the control option
(For every task this will be available).这可以通过
control option
下的Custom Condition
来完成(对于每个任务,这都可用)。
You can achieve this by defining a specific conditions to run the specific task.您可以通过定义特定条件来运行特定任务来实现这一点。
In your case, you want to run the task when your version no is 0
.在您的情况下,您希望在版本号为
0
时运行该任务。 So you just define the custom conditions
in the control Options
to speific the codntion like所以你只需在
control Options
定义custom conditions
来指定像
and(succeeded(), eq(variables['Release.Artifacts._TheBuild.BuildNumber'], '0'))
So this task will execute only when the condtion satisify else the task will skip it's exectuion.所以这个任务只有在条件满足时才会执行,否则任务将跳过它的执行。
If I understood correctly, you only want to deploy builds that have a version number that ends with .0
如果我理解正确,您只想部署版本号以
.0
结尾的版本
You can try adding a release pipeline Continuous Deployment Trigger and add a branch filter that only searches for the version number via a tag .您可以尝试添加发布管道持续部署触发器并添加仅通过标签搜索版本号的分支过滤器。
To do this, first go to the release you want to change, click on the ... ellipsis next to the release name, and click Edit.为此,首先转到要更改的版本,单击版本名称旁边的 ... 省略号,然后单击编辑。
This should bring you to the release's pipeline view.这应该会将您带到发布的管道视图。 Once here, click on the little lighting bolt icon to open the Continuous Deployment Trigger editor:
在这里,单击小闪电图标以打开持续部署触发器编辑器:
This should open the editor on the right hand side.这应该会打开右侧的编辑器。 Here you'll see a place to edit Build branch filters.
在这里你会看到一个编辑构建分支过滤器的地方。 Click on the + Add button to add one.
单击 + 添加按钮添加一个。
A new row will popup for you to configure your filter.将弹出一个新行供您配置过滤器。 It's here where I believe you can filter for your version number via build tag.
在这里,我相信您可以通过构建标记过滤您的版本号。
Obviously, you will have to edit your build pipeline as well to add this tag so that you can filter for it here in the release.显然,您还必须编辑您的构建管道以添加此标签,以便您可以在发布中的此处对其进行过滤。
You would add this tag in the Build tags input.您将在构建标签输入中添加此标签。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.