Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Pull Request Build and skip other stages

I am using multi stage YAML pipelines in Azure DevOps and Where I build in one stage and deploy the artifact to other stages. I have setup a Pull Request build and whenever a new code is pushed all stages in the pipeline are running, which is not desirable.

what i want is whenever a new code is pushed to any branch i want to run the build stage and skip the deploy stages. This option is available by default classic pipeline as build and release are a seperate component earlier

like image 484
Sar Avatar asked Oct 19 '25 11:10

Sar


1 Answers

You need to add condition to skip stage/step for pull request builds. You can do using this:

ne(variables['Build.Reason'], 'PullRequest')

For example:

- stage: B
  condition: and(succeeded(), ne(variables['Build.Reason'], 'PullRequest'))
  jobs:
  - job: B1
    steps:
      - script: echo This is not PR trigger

You will find more examples like this here

like image 66
Krzysztof Madej Avatar answered Oct 22 '25 03:10

Krzysztof Madej



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!