Azure-devops-cli-extension: [Feature Request] az pipeline build queue wait for completion

Created on 8 Aug 2019  路  8Comments  路  Source: Azure/azure-devops-cli-extension

Problem: it's complex to create a simple batch file which does something when the build is complete. Currently the batch file would need to handle the json response and poll status to determine build completion.

Proposal: Add az pipelines build queue --wait-for-build-complete. Block until build completes. A non-zero exit code would be returned if build is something other than successful. Very simple to sequence in a batch file.

Example batch file / check in script might be:
git push
az pipelines build queue --wait-for-build-complete
if ERRORLEVEL 1 (
echo investigate it!!!
exit /b 1 )
git pull
init
(etc)

Feature

Most helpful comment

Proposal

  1. Include --wait as the parameter for indicating that the user wants to explicitly wait for the pipeline creation.
  2. Provide the same experience as that of az extension add to provide feedback that the command is undertaking an action at present
    Creating pipeline [pipeline name] ...
  3. Protection against long run time: @gauravsaralMs - could you advise the checks that need to be in place here?

All 8 comments

To clarify, this is still automation use case, but the need is around simpler scripting that lets you eliminate potentially unnecessary polling right?

@geverghe Yes, that would make the automation easier.
The same parameter could also be added to az pipelines create

Thank you for the confirmation. We will evaluate how we can prioritize this ask based on the community feedback/reaction. Feel free to contribute as well - we can guide you in case you have any issues.

Proposal

  1. Include --wait as the parameter for indicating that the user wants to explicitly wait for the pipeline creation.
  2. Provide the same experience as that of az extension add to provide feedback that the command is undertaking an action at present
    Creating pipeline [pipeline name] ...
  3. Protection against long run time: @gauravsaralMs - could you advise the checks that need to be in place here?

With regard to long runtime, my suggestion is for the CLI run indefinitely by default (relying on the timeout on the invoked workflow), to avoid the surprise of having the CLI introduce a timeout-error to a long-running build process. (of course, control-C should cancel and exit with >0 exit code).

Consider workflows that have an extended stress test run or manual approval process that can run for days / weeks.

Hello guys, is there any news on this? Thanks!

Any update on this, please? It's 2021 already, you know.

As we don't have a way to wait for the completion of a pipeline, I am using the following wait logic (powershell).
Hope this may help until the feature is available. :)

$buildQueue = (az pipelines build queue --organization $organization
--project $project `
--definition-name $definitionName) | ConvertFrom-Json
$buildNumber = $buildQueue.buildNumber

if ($null -ne $buildNumber)
{
# Get the status of triggered build
$buildDetails = (az pipelines build show --id $buildQueue.id
--detect true --organization $organization
--project $project) | ConvertFrom-Json

while ($buildDetails.status -ne "completed")
{
    Start-Sleep -Seconds 10
    if ($buildDetails.status -eq "notStarted")
    {
        $messageQueued = "$definitionName with build number $buildNumber is queued..."
        Write-Host $messageQueued -ForegroundColor Green
    }
    if ($buildStatus -eq "canceled" -Or $buildStatus -eq "failed")
    {
        Write-Error "The build number $buildNumber is $buildStatus"
    }
# Get the status of the triggered build again
$buildDetails = (az pipelines build show  `
    --id $buildQueue.id `
    --detect true `
    --organization $organization `
    --project $project) | ConvertFrom-Json
}

}

Was this page helpful?
0 / 5 - 0 ratings

Related issues

atbagga picture atbagga  路  3Comments

bentterp picture bentterp  路  4Comments

f00-beerd picture f00-beerd  路  3Comments

benc-uk picture benc-uk  路  4Comments

ishitam8 picture ishitam8  路  6Comments