4

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

2 Answers 2

4

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
Sign up to request clarification or add additional context in comments.

1 Comment

Thank you Patrick for your response! I will definitely look into your solution. I leave the question "unsolved" for know and hope you or anyone else can give an update if/when this is supported in Azure DevOps.
2

Now this is not possible. Your pipeline will fire in case of any of defined trigger pass. So if you need sth like this you need to build using webhooks. You can for instance call Azure Function when your pipeline succeeded. Keep there a track in some database or other form of state that pipeline A was run for commit 32563456 and then when Pipeline B will run for the same commit and your function is being notified you will trigger this pipeline from Azure Function.

I know that this sound like plenty of work but this is not supported to have out of the box.

1 Comment

Thank you Krzysztof for your response. I will look into this!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.