CI/CD Deployment Conditions Not Triggering

断了今生、忘了曾经 提交于 2019-12-22 00:21:56

问题


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).

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:

EDIT: 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.


回答1:


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.



来源:https://stackoverflow.com/questions/45149289/ci-cd-deployment-conditions-not-triggering

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!