trigger a problem with azure pipelines via ui

Agree with Cece.

As a workaround, we could add task power shell and call the API Queue build to trigger the build.

Steps:

Create PAT token->save it in the build pipeline variable and save it secret.

Add task power shell and set the condition to Even if a previous task has failed, even if the build was canceled

enter image description here

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
write-host $response

Result:

enter image description here

CLICK HERE to find out more related problems solutions.

Leave a Comment

Your email address will not be published.

Scroll to Top