* Added build cancel command

* Added test case for build cancel command

* Reverted local vs code launch settings

* Resolved merge conflicts

* Fixed styling issue

* Updated parameter name for build cancel method
This commit is contained in:
Mathivanan Palanisamy 2022-10-26 10:53:31 +05:30 коммит произвёл GitHub
Родитель 53cab5488d
Коммит 81abbb9685
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
4 изменённых файлов: 504 добавлений и 0 удалений

Просмотреть файл

@ -123,6 +123,24 @@ def build_list(definition_ids=None, branch=None, organization=None, project=None
return builds
def build_cancel(build_id, open=False, organization=None, project=None, detect=None):
"""Cancels if build is running.
:param build_id: ID of the build.
:type build_id: int
:param open: Open the build results page in your web browser.
:type open: bool
:rtype: :class:`<Build> <v5_0.build.models.Build>`
"""
organization, project = resolve_instance_and_project(
detect=detect, organization=organization, project=project)
client = get_build_client(organization)
build = Build(status="Cancelling")
build = client.update_build(build=build, project=project, build_id=build_id)
if open:
_open_build(build, organization)
return build
def add_build_tags(build_id, tags, organization=None, project=None, detect=None):
"""Add tag(s) for a build.
:param build_id: ID of the build.

Просмотреть файл

@ -116,6 +116,7 @@ def load_build_commands(self, _):
g.command('list', 'build_list', table_transformer=transform_builds_table_output)
g.command('queue', 'build_queue', table_transformer=transform_build_table_output)
g.show_command('show', 'build_show', table_transformer=transform_build_table_output)
g.command('cancel', 'build_cancel', table_transformer=transform_build_table_output)
with self.command_group('pipelines build tag', command_type=buildOps) as g:
# basic build tag commands

Различия файлов скрыты, потому что одна или несколько строк слишком длинны

Просмотреть файл

@ -0,0 +1,31 @@
# --------------------------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License.txt in the project root for license information.
# --------------------------------------------------------------------------------------------
import os
import unittest
from azure_devtools.scenario_tests import AllowLargeResponse
from .utilities.helper import DevopsScenarioTest, disable_telemetry, set_authentication, get_test_org_from_env_variable
DEVOPS_CLI_TEST_ORGANIZATION = get_test_org_from_env_variable() or 'Https://dev.azure.com/dhilmathy'
class PipelinesBuildCancelTests(DevopsScenarioTest):
@AllowLargeResponse(size_kb=3072)
@disable_telemetry
@set_authentication
def test_build_cancel(self):
self.cmd('az devops configure --defaults organization=' + DEVOPS_CLI_TEST_ORGANIZATION + ' project=buildtests')
build_definition_name = 'BuildTests Definition1'
#QueueBuild to get a build ID
queue_build_command = 'az pipelines build queue --definition-name "' + build_definition_name + '" --detect false --output json'
queue_build_output = self.cmd(queue_build_command).get_output_in_json()
queued_build_id = queue_build_output["id"]
#Cancel the running build
cancel_running_build_command = 'az pipelines build cancel --id ' + str(queued_build_id) + ' --detect false --output json'
cancel_running_build_output = self.cmd(cancel_running_build_command).get_output_in_json()
assert cancel_running_build_output["status"] == "cancelling"