CI/CD部署条件未触发 [英] CI/CD Deployment Conditions Not Triggering

本文介绍了CI/CD部署条件未触发的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经为此战斗了整整一天.我在VSTS CI/CD管道中有一个简单的要求,我正在尝试构建遵循模式release/*hotfix/*的任何分支都应触发对我的QA环境的部署.这是我基于分支的配置:

I've been fighting with this for over a day now. I have a simple requirement inside of a VSTS CI/CD pipeline that I'm trying to build that any branch following the pattern release/* or hotfix/* should trigger a deployment to my QA environment. Here is my branch based configuration:

此配置未按预期触发部署.正如您在下面的屏幕快照中看到的那样,该版本已运行,但并未在我的任何环境中触发. (质量检查"是位于右边的第二个灰色方块,根据部署是成功还是失败,应为绿色或红色).

This configuration does not trigger the deployment as expected. As you can see in the screenshot below the release ran but did not trigger against any of my environments. (QA is the second grey square from the right and should be green or red depending on whether the deployment succeeded or failed).

为解决此问题,我尝试改用构建标签.我添加了一个Powershell步骤,该步骤根据分支的名称有条件地添加了构建标签.

In an attempt to work around this, I tried using Build Tags instead. I added a Powershell step that conditionally adds Build Tags based on the name of the branch.

$branchName = $Env:BUILD_SOURCEBRANCH

if ($branchName -like '*release/*')
{
    Write-Host "##vso[build.addbuildtag]release"
}

if ($branchName -like '*hotfix/*')
{
    Write-Host "##vso[build.addbuildtag]hotfix"
}

这正确设置了构建标签,正如我在构建工件上以及应用该标签的日志中所看到的那样.但是,将我的部署条件"修改为可识别标记"会导致行为与我尝试使用分支完全相同:

This correctly sets the Build Tags as I can see right on the build artifact and in logs that the tag was applied. However, modifying my Deployment Conditions to be Tag aware results in exactly the same behavior as my attempt using branches:

根据要求,这是配置项定义,其中显示了获取源"步骤.这里没有添加多个分支条件的选项.它们在触发器"部分中设置.

As requested, here is the CI definition with the Get Sources step shown. There is no option to add multiple branch conditions here. They are set in the Triggers section.

推荐答案

这通常是由于同时配置两个不同的条件引起的,因为VSTS在此使用"AND"运算符而不是"OR"运算符.在这种情况下,部署条件将如下所示:"Artifact Branch from Release/*" AND "Artifact Branch from Feature/*"无法满足.如果双击"Release 28"将其打开,然后将鼠标移到"i"图标上,则应该看到未触发它的原因.请检查是否是我上面提到的原因.

This is usually caused by two different conditions are configured in the same time since VSTS use "AND" operator rather than "OR" operator here. In this scenario, the deployment condition would like this: "Artifact Branch from Release/*" AND "Artifact Branch from Feature/*" which cannot be met. If you double click on the "Release 28" to open it and move your mouse on the "i" icon, you should see the reason why it is not triggered. Please check if it is the reason I mentioned above.

解决方法是创建一个新的部署环境,并从质量检查"中克隆设置,然后在这两个环境中分开两个条件.

The workaround is create a new deployment environment and clone the settings from QA and then separate the two conditions in the two environments.

这篇关于CI/CD部署条件未触发的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆