Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Chaining Azure DevOps pipelines

I want the Azure DevOps pipeline below to automatically trigger when both resource pipelines successfully has built the same commit of master. Is this possible? Right now it triggers when one of the pipelines is finished resulting in two runs.

trigger: none
pr: none

resources:
  pipelines:
    - pipeline: "buildPipeline1"
      source: "BuildPipeline1"
      trigger:
        branches:
        - master

    - pipeline: "buildPipeline2"
      source: "BuildPipeline2"
      trigger:
        branches:
        - master
like image 797
Gustav Gahm Avatar asked Oct 29 '25 16:10

Gustav Gahm


1 Answers

Sorry, it's not possible for now.

For pipeline triggers, we could only trigger a pipeline upon the completion of another, specify the triggering pipeline as a pipeline resource.

You could refer our official doc here-- Trigger one pipeline after another

The only workaround I could come across, add a task in the end of your two pipelines, query the other pipeline's status if the same commit built and built succeed.

Finally we can add task power shell and add script to call the REST API to queue the build/any other pipeline based on previous task result.

$connectionToken="PAT"
$base64AuthInfo= [System.Convert]::ToBase64String([System.Text.Encoding]::ASCII.GetBytes(":$($connectionToken)"))
$PipelineUrl = "https://dev.azure.com/{Org name}/{project name}/_apis/pipelines/{Pipeline ID}/runs?api-version=6.0-preview.1" 

$body ="{ 
 `"resources`":{
        `"repositories`":{
            `"self`":{`"refName`":`"refs/heads/master`"
            }
         }
    }
}"
$Pipelines = Invoke-RestMethod -Uri $PipelineUrl -ContentType "application/json" -Body $body -Headers @{Authorization=("Basic {0}" -f $base64AuthInfo)} -Method POST
like image 53
PatrickLu-MSFT Avatar answered Oct 31 '25 10:10

PatrickLu-MSFT



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!