1
votes

I have build and release definition in azure-devops. I want the build to be triggered after release is done, I don't repeat the steps, I want to trigger already existing build definition. I am trying to figure how to do this in azure-devops.

When I tell build it is end to end test. The idea is to run the end to end test after release is done. Note I already have E2E Tests build, here I have repeated the steps, instead I want to just refer the existing build and trigger it. Any suggestion or help on how to do this will be of great help.

enter image description here

1
Hi, Is there any update about this ticket? Feel free to let me know if you have any questions. If the answer could help, you may consider accepting it. Thanks.Vito Liu
Thanks @VitoLiu-MSFT :)karansys

1 Answers

2
votes

This is not currently supported. This document has all Azure DevOps trigger events. Currently release completion cannot trigger a build.

As a workaround, we could open release definition and add task power shell at the end to call REST API to trigger build.

Power shell script:

$token = "{PAT}"   
$url = "https://dev.azure.com/{Org name}/{project name}/_apis/build/builds?api-version=6.1-preview.6"
$token = [System.Convert]::ToBase64String([System.Text.Encoding]::ASCII.GetBytes(":$($token)"))


$JSON = @"
{
  "definition": {
    "id": {Build Definition ID}
  }
}
"@

$response = Invoke-RestMethod -Uri $url -Headers @{Authorization = "Basic $token"} -Method Post -ContentType application/json -body $JSON

Also, we could add the extension Trigger Azure DevOps Pipeline and then add task Trigger Azure DevOps Pipeline at the end of the job to trigger build.

Result:

enter image description here