0

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?

sanjai
  • 128
  • 1
  • 1
  • 13
  • Not get your latest information, is the workaround helpful for you? If it is helpful, you could [Accept it as an Answer](https://meta.stackexchange.com/questions/5234/how-does-accepting-an-answer-work), so it could help other community members who get the same issues and we could archive this thread. Or if you have any concern, feel free to share it here. Thanks. – Hugh Lin Nov 18 '20 at 06:55

1 Answers1

1

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

Hugh Lin
  • 17,829
  • 2
  • 21
  • 25