Azure-devops-cli-extension: [New command] Command to cancel build pipeline

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

Is there a command line to cancel build pipeline? I know we can run the pipeline but I want to cancel it also. Thanks

help wanted Feature

Most helpful comment

@jopham-sage The API for cancelling the build is documented here.

PATCH https://dev.azure.com/atbagga/atbagga/_apis/build/Builds/120
Request content: {'status': 'Cancelling'}

You can use the following command as a workaround for the time being until this issue is prioritised and we add a command in CLI for the same.

az devops invoke --area build --resource builds --route-parameters buildId=120 project=atbagga --in-file D:/patch.txt  --http-method patch 

Content in patch.txt -

{'status': 'Cancelling'}

All 15 comments

@geverghe Hi am looking for Azure Dev Ops CLI command to cancel build pipeline. There's a delete CLI command but I think that's deleting the build. I haven't tried that command but I'll test and see. Thanks.

So there are two elements - there is a build definition delete and there is a build delete. I think this build delete corresponds to canceling the build run. You can potentially give it a shot with az devops invoke to run this api till we build a command

Looks like delete, as the verb indicates, deletes the run and therefore stops the run. However, I think your use case is just cancel. @atbagga is looking into the update API and will get back to you on the API that can be used via invoke till we build a full fledged command.

@jopham-sage The API for cancelling the build is documented here.

PATCH https://dev.azure.com/atbagga/atbagga/_apis/build/Builds/120
Request content: {'status': 'Cancelling'}

You can use the following command as a workaround for the time being until this issue is prioritised and we add a command in CLI for the same.

az devops invoke --area build --resource builds --route-parameters buildId=120 project=atbagga --in-file D:/patch.txt  --http-method patch 

Content in patch.txt -

{'status': 'Cancelling'}

@atbagga I would like to take up this.

I am planning to create a new update command. Something like az pipelines build update --status Cancelling. Your thoughts & comments?

@dhilmathy Sorry missed the update. If you are still up for it please share the detailed command signature and go ahead.

Whats the status of this ? Is there any way to cancel or delete a run via cli ?

@atbagga I am planning to introduce a new command called cancel.

Command signature

    az pipelines build cancel : Cancels if build is running.

Arguments
    --id      [Required] : ID of the build.
    --detect             : Automatically detect organization.  Allowed values: false, true.
    --open               : Open the build results page in your web browser.
    --org --organization : Azure DevOps organization URL. You can configure the default organization
                           using az devops configure -d organization=ORG_URL. Required if not
                           configured as default or picked up via git config. Example:
                           https://dev.azure.com/MyOrganizationName/.
    --project -p         : Name or ID of the project. You can configure the default project using az
                           devops configure -d project=NAME_OR_ID. Required if not configured as
                           default or picked up via git config.

Will submit a PR if above command seems fine for you. Thanks!

@dhilmathy Sorry, I am not a maintainer in this repo anymore.
Tagging the owners for attention.. @Azure/azure-devops-cli

@dhilmathy what's the status of this new command?

I would use this to find a workaround for this outstanding feature request

@dhilmathy what's the status of this new command?

I would use this to find a workaround for this outstanding feature request

@dsfrederic, I'd created the command based on the proposal I'd made earlier. I am waiting for maintainers comment before raising PR.

@atbagga @elbatk @mitsha-microsoft can any of you guys help us out?

Thanks @dhilmathy for the PR. I see the project owners are added as PR reviewers.

@jopham-sage The API for cancelling the build is documented here.

PATCH https://dev.azure.com/atbagga/atbagga/_apis/build/Builds/120
Request content: {'status': 'Cancelling'}

You can use the following command as a workaround for the time being until this issue is prioritised and we add a command in CLI for the same.

az devops invoke --area build --resource builds --route-parameters buildId=120 project=atbagga --in-file D:/patch.txt  --http-method patch 

Content in patch.txt -

{'status': 'Cancelling'}

Had to fix the contents of the patch.txt file to make it valid json. the single quotes changed double quotes. After I did that, it worked:

{"status": "Cancelling"}

Also had to add --org parameter

Was this page helpful?
0 / 5 - 0 ratings