Search code examples
azureazure-devops

"Build after the previous execution has succeeded" in Azure Devops


I have a an Azure Pipeline A, that executes a deployment to my Salesforce org in the event of a PR merge.

My problem statement is,

I am not able to restrict the execution of this pipeline such that it executes only after the previous execution of the same pipeline has completed.

In other words, if this pipeline is triggered by multiple PR's, then I would want only once instance of the pipeline to run. The next one should wait until the previous run has been completed.

Is there a way to achieve this?


Solution

  • If you are using YAML you should be able to use the following trigger:

    trigger:
      batch: true
      branches:
        include:
          - your-branch
    

    The most relevant part of the documentation:

    If you set batch to true, when a pipeline is running, the system waits until the run is completed, then starts another run with all changes that have not yet been built. By default, batch is false. batch is not supported in repository resource triggers.

    https://learn.microsoft.com/en-us/azure/devops/pipelines/yaml-schema/trigger?view=azure-pipelines#properties