[英]"Run this job" when sourceFolder contains a folder in Azure Release Pipeline
I have Azure pipeline, i need to stop the pipeline when the sourceFolder doesn't contains a specific folder.我有 Azure 管道,当 sourceFolder 不包含特定文件夹时,我需要停止管道。
For Ex: if my sourceFolder contains /home/vsts/work/1/s/projectName/src/app/pos - pipeline should run例如:如果我的 sourceFolder 包含 /home/vsts/work/1/s/projectName/src/app/pos - 管道应该运行
if my sourceFolder contains /home/vsts/work/1/s/projectName/src/app/ecomm - pipeline should not run如果我的 sourceFolder 包含 /home/vsts/work/1/s/projectName/src/app/ecomm - 管道不应运行
how do i mention the condition in Azure pipeline Demands / Custom Conditions?我如何在 Azure 管道需求/自定义条件中提及条件?
As a workaround, you can first create a custom variable( RunPipeline
) with a value of False
.作为解决方法,您可以先创建一个值为
False
的自定义变量 ( RunPipeline
)。 Then add a new agent job, add a powershell task to this job, in the powershell task, traverse the source folders through the script, if there is a folder named pos
, change the value of variable to True
.然后添加一个新的agent job,在这个job中添加一个powershell任务,在powershell任务中,通过脚本遍历源文件夹,如果有名为
pos
的文件夹,将变量的值改为True
。
Sample inline script:示例内联脚本:
Get-ChildItem –Path "$(System.DefaultWorkingDirectory)" |
Foreach-Object {
if($_.Name --eq 'pos'){ Write-Host "##vso[task.setvariable variable=runPipeline;isOutput=true]True" }
}
Then add custom condition in the Additional options
of the next job, for example: eq(variables['RunPipeline'], 'True')
.然后在下一个作业的
Additional options
中添加自定义条件,例如: eq(variables['RunPipeline'], 'True')
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.