I have set up where we have the Application build release pipeline & test automation release pipeline are separate.Currently whenever there is build created then test automation starts which is wrong as build artifacts are just published but not yet deployed which will be done by the release pipeline. So I am looking for a solution where I can add the trigger to the test release pipeline where It will check build release pipeline is completed & code is deployed to the environment.
-
1https://stackoverflow.com/help/how-to-ask provides useful information on how to compose a question that will attract answers. – WaitingForGuacamole Mar 07 '21 at 21:02
2 Answers
If you have this in one yml file you can use dependsOn
on buildStage
and deployStage
and condition
for success status of previous stages in AutomationTestsStage
stage
stages:
- stage: 'AutomationTestsStage'
dependsOn:
- buildStage
- deployStage
condition: succeeded()

- 935
- 7
- 18
According to your description, you have three pipeline, build pipeline(build and publish artifacts), Application release pipeline and test automation release pipeline. You have set up a CD trigger that will trigger the release pipeline together after the pipeline is completed. But the order in which you want the pipeline to run is build pipeline->Application release pipeline->test automation release pipeline, right?
So I am looking for a solution where I can add the trigger to the test release pipeline where It will check build release pipeline is completed & code is deployed to the environment.
As a workaround, we need to open test automation release pipeline definition and disable the CD trigger, then open open Application release pipeline, add task power shell at the end of the job and call the REST API to trigger release pipeline(test automation release pipeline).
Power shell Script:
$token = "{PAT}"
$url = "https://vsrm.dev.azure.com/{Org name}/{Project name}/_apis/Release/releases?api-version=5.0"
$token = [System.Convert]::ToBase64String([System.Text.Encoding]::ASCII.GetBytes(":$($token)"))
$JSON = @"
{
"definitionId": {test automation release pipeline definition ID}
}
"@
$response = Invoke-RestMethod -Uri $url -Headers @{Authorization = "Basic $token"} -Method Post -ContentType application/json -body $JSON
}
In addition, we need set the Power Shell condition to Only when all previous tasks have succeeded
, check the pic below.
And now, it will run the release test automation release pipeline after build release pipeline is completed & code is deployed to the environment

- 7,525
- 1
- 8
- 17
-
Thank you.You exactly got my problem.How to get the parameter definitionId of test automation release?Is it dynamic or always same? – subodh mirgal Mar 08 '21 at 08:12
-
Hi @subodhmirgal, The definitionId is the pipeline ID of tests automation release pipeline, if you do not want to trigger release pipeline, it should always be the same. – Vito Liu Mar 11 '21 at 05:42
-
1The issue has been resolved & successfully implemented. Thank you Vito – subodh mirgal Mar 12 '21 at 10:41
-
Hi @subodhmirgal, If this answer is helpful, would you please [accept it as the answer](https://meta.stackexchange.com/questions/5234/how-does-accepting-an-answer-work/5235#5235)? So it could help other community members who get the same issues and we could archive this thread. Thanks. Have a nice day. :) – Vito Liu Mar 15 '21 at 01:44