简体   繁体   English

当 sourceFolder 包含 Azure 发布管道中的文件夹时,“运行此作业”

[英]"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.

相关问题 “Run this job” based on value in angular.json in Azure Release Pipeline - “Run this job” based on value in angular.json in Azure Release Pipeline Azure 发布管道 - 仅在 VM 可用时运行代理作业 - Azure Release Pipeline - Only run agent job if VM is available 将 output 传递给 azure 发布管道中的新作业 - Pass output to new job in azure release pipeline 在 Azure DevOps 发布管道中控制作业顺序 - Control Job Order in Azure DevOps Release Pipeline 并发管道的概念是什么(Azure Pipeline 中的一个并行作业允许您在任何给定时间运行单个生成或发布作业)? - What is the concept of concurrent pipelines (One parallel job in Azure Pipeline lets you run a single build or release job at any given time)? Azure DevOps - 使用部署组或部署作业向环境发布管道? - Azure DevOps - Release Pipeline using Deployment Groups or Deployment Job to an Environment? 尝试创建 Azure 发布/运行 Azure 发布管道发布返回错误 400 - Attempt to create an Azure release/run Azure release pipeline release returns error 400 Azure Devops - 基于对相应文件夹的提交触发发布管道 - Azure Devops - Trigger Release pipeline based on commit to respective folder 了解Azure发布管道 - Understanding Azure Release Pipeline Azure DevOps 发布管道 - Azure Devops Release Pipeline
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM