sanjai
sanjai

Reputation: 116

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

For Ex: if my sourceFolder contains /home/vsts/work/1/s/projectName/src/app/pos - pipeline should run

if my sourceFolder contains /home/vsts/work/1/s/projectName/src/app/ecomm - pipeline should not run

how do i mention the condition in Azure pipeline Demands / Custom Conditions?

Upvotes: 0

Views: 290

Answers (1)

Hugh Lin
Hugh Lin

Reputation: 19471

As a workaround , you can first create a custom variable(RunPipeline) with a value of False. 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.

enter image description here

enter image description here

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

enter image description here

Upvotes: 1

Related Questions