Am triggering a build Pipeline from a release Pipeline as a first task through an API call and that doesn't have any Issue.
Second Task - Pipeline needs to wait Until the triggered Pipeline from the first task is completed and then go to Third Task. How do i achieve It ?
I have tried below in a powershell task to get the Build ID from the running pipeline and tried to wait through a loop, but am unable to get the Build Id
First Task to trigger a Build Pipeline
curl -L -X POST 'https://dev.azure.com/Org/project/_apis/build/builds?definitionId-1549&api-version=6.1-preview.6' -H 'Authorization: $(ADO_BASIC_AUTH)' -H 'Content-Type: application/json' --data '{"definition": {"id": 1549}}'
Second Task as you Suggested
$B64Pat = [Convert]::ToBase64String([System.Text.Encoding]::UTF8.GetBytes(":$(ADO_BASIC_AUTH)"))
$header = @{ Authorization = "Basic $B64Pat" }
$continueCurrent = $true
$uriGetActiveBuilds1 = "https://dev.azure.com/org/project/_apis/build/builds?definitions=1549&statusFilter=inProgress,notStarted&api-version=5.1"
do
{
$continueCurrent = $true
$resultStatus = Invoke-RestMethod -Uri $uriGetActiveBuilds1 -Method Get -ContentType "application/json" -Headers $header
if ($resultStatus.count -gt 0)
{
$continueCurrent = $false
Write-Host " . "
Start-Sleep -s 10
}
}while($continueCurrent -eq $false)
Write-Host "Continue task"
The Second keeps waiting even If the Build Pipeline triggered from the First Task is completed
Output of my Pipeline