def pipeline_show(id=None, name=None, open=False, organization=None, project=None, # pylint: disable=redefined-builtin folder_path=None, detect=None): """ Get the details of a pipeline. :param id: ID of the pipeline. :type id: int :param name: Name of the pipeline. Ignored if --id is supplied. :type name: str :param folder_path: Folder path of pipeline. Default is root level folder. :type folder_path: str :param open: Open the pipeline summary page in your web browser. :type open: bool :param detect: Automatically detect values for instance and project. Default is "on". :type detect: str """ organization, project = resolve_instance_and_project( detect=detect, organization=organization, project=project) client = get_build_client(organization) if id is None: if name is not None: id = get_definition_id_from_name(name, client, project, path=folder_path) else: raise CLIError("Either the --id argument or the --name argument must be supplied for this command.") build_definition = client.get_definition(definition_id=id, project=project) if open: _open_pipeline(build_definition, organization) return build_definition
def pipeline_folder_list(path=None, query_order=None, organization=None, project=None, detect=None): """ List all folders. :param path: Full path of the folder. :type path: str :param query_order: Order in which folders are returned. :type query_order: str :param project: Name or ID of the team project. :type project: str :param detect: Automatically detect organization and project. Default is "on". :type detect: str """ organization, project = resolve_instance_and_project( detect=detect, organization=organization, project=project) client = get_build_client(organization) if query_order: if query_order.lower() == 'asc': query_order = 'folderAscending' elif query_order.lower() == 'desc': query_order = 'folderDescending' return client.get_folders(path=path, query_order=query_order, project=project)
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. :type build_id: int :param tags: Tag(s) to be added to the build. [Comma seperated values] :type tags: str :rtype: list of str """ organization, project = resolve_instance_and_project( detect=detect, organization=organization, project=project) client = get_build_client(organization) tags = list(map(str, tags.split(','))) if len(tags) == 1: tags = client.add_build_tag(project=project, build_id=build_id, tag=tags[0]) else: tags = client.add_build_tags(tags=tags, project=project, build_id=build_id) return tags
def pipeline_variable_delete(name, pipeline_id=None, pipeline_name=None, organization=None, project=None, detect=None): """Delete a variable from pipeline :param pipeline_id: Id of the pipeline. :type pipeline_id: int :param pipeline_name: Name of the pipeline. :type pipeline_name: str :param name: Name of the variable to delete. :type name: str """ organization, project = resolve_instance_and_project( detect=detect, organization=organization, project=project) if pipeline_id is None and pipeline_name is None: raise ValueError('Either the --pipeline-id or --pipeline-name argument ' + 'must be supplied for this command.') pipeline_client = get_build_client(organization) if pipeline_id is None: pipeline_id = get_definition_id_from_name(name, pipeline_client, project) # get pipeline definition pipeline_definition = pipeline_client.get_definition(definition_id=pipeline_id, project=project) key_to_delete = None # Check if the variable already exists key = None if pipeline_definition.variables: for key in pipeline_definition.variables.keys(): if key.lower() == name.lower(): key_to_delete = key break if not key_to_delete: raise CLIError('Variable \'{}\' does not exist. '.format(name)) _ = pipeline_definition.variables.pop(key) _ = pipeline_client.update_definition(project=project, definition_id=pipeline_id, definition=pipeline_definition) print('Deleted variable \'{}\' successfully.'.format(key_to_delete))
def build_definition_list(name=None, top=None, organization=None, project=None, repository=None, repository_type=None, detect=None): """List build definitions. :param name: Limit results to definitions with this name or starting with this name. Examples: "FabCI" or "Fab*" :type name: bool :param top: Maximum number of definitions to list. :type top: int :param repository: Limit results to definitions associated with this repository. :type repository: str :param repository_type: Limit results to definitions associated with this repository type. It is mandatory to pass 'repository' argument along with this argument. :type repository_type: str :rtype: [BuildDefinitionReference] """ organization, project, repository = resolve_instance_project_and_repo( detect=detect, organization=organization, project=project, repo=repository) client = get_build_client(organization) query_order = 'DefinitionNameAscending' repository_type = None if repository is not None: if repository_type is None: repository_type = 'TfsGit' if repository_type.lower() == 'tfsgit': resolved_repository = _resolve_repository_as_id(repository, organization, project) else: resolved_repository = repository if resolved_repository is None: raise ValueError("Could not find a repository with name '{}', in project '{}'." .format(repository, project)) else: resolved_repository = None definition_references = client.get_definitions(project=project, name=name, repository_id=resolved_repository, repository_type=repository_type, top=top, query_order=query_order) return definition_references
def build_definition_show( id=None, name=None, open=False, organization=None, project=None, # pylint: disable=redefined-builtin detect=None): """Get the details of a build definition. :param id: ID of the definition. :type id: int :param name: Name of the definition. Ignored if --id is supplied. :type name: str :param open: Open the definition summary page in your web browser. :type open: bool :rtype: BuildDefinitionReference """ organization, project = resolve_instance_and_project( detect=detect, organization=organization, project=project) client = get_build_client(organization) if id is None: if name is not None: id = get_definition_id_from_name(name, client, project) else: raise ValueError( "Either the --id argument or the --name argument must be supplied for this command." ) build_definition = client.get_definition(definition_id=id, project=project) if open: _open_definition(build_definition, organization) return build_definition
def pipeline_folder_create(path, description=None, organization=None, project=None, detect=None): """ Create a folder. :param path: Full path of the folder. :type path: str :param description: Description of the folder. :type description: str :param project: Name or ID of the team project. :type project: str :param detect: Automatically detect organization and project. Default is "on". :type detect: str """ organization, project = resolve_instance_and_project( detect=detect, organization=organization, project=project) client = get_build_client(organization) from azext_devops.devops_sdk.v5_0.build.models import Folder folder = Folder() folder.description = description folder.path = path new_folder = client.create_folder(folder=folder, path=path, project=project) return new_folder
def build_queue( definition_id=None, definition_name=None, branch=None, variables=None, open=False, # pylint: disable=redefined-builtin organization=None, project=None, detect=None, commit_id=None, queue_id=None): """Request (queue) a build. :param definition_id: ID of the definition to queue. Required if --name is not supplied. :type definition_id: int :param definition_name: Name of the definition to queue. Ignored if --id is supplied. :type definition_name: str :param branch: Branch to build. Required if there is not a default branch set up on the definition. Example: "dev". :type branch: str :param variables: Space separated "name=value" pairs for the variables you would like to set. :type variables: [str] :param open: Open the build results page in your web browser. :type open: bool :param commit_id: Commit ID of the branch to build. :type commit_id: str :param queue_id: Queue Id of the pool that will be used to queue the build. :type queue_id: str :rtype: :class:`<Build> <v5_0.build.models.Build>` """ organization, project = resolve_instance_and_project( detect=detect, organization=organization, project=project) if definition_id is None and definition_name is None: raise ValueError( 'Either the --definition-id argument or the --definition-name argument ' + 'must be supplied for this command.') client = get_build_client(organization) if definition_id is None: definition_id = get_definition_id_from_name(definition_name, client, project) definition_reference = DefinitionReference(id=definition_id) build = Build(definition=definition_reference) build.source_branch = resolve_git_ref_heads(branch) build.source_version = commit_id if queue_id is not None: build.queue = AgentPoolQueue() build.queue.id = queue_id if variables is not None and variables: build.parameters = {} for variable in variables: separator_pos = variable.find('=') if separator_pos >= 0: build.parameters[ variable[:separator_pos]] = variable[separator_pos + 1:] else: raise ValueError( 'The --variables argument should consist of space separated "name=value" pairs.' ) queued_build = client.queue_build(build=build, project=project) if open: _open_build(queued_build, organization) return queued_build
def pipeline_run_show(id, open=False, organization=None, project=None, detect=None): # pylint: disable=redefined-builtin """Show details of a pipeline run. :param id: ID of the pipeline run. :type id: int :param open: Open the build results page in your web browser. :type open: bool :param organization: Azure Devops organization URL. Example: https://dev.azure.com/MyOrganizationName/ :type organization: str :param project: Name or ID of the team project. :type project: str :param detect: Automatically detect organization and project. Default is "on". :type detect: str :rtype: :class:`<Build> <build.v5_1.models.Build>` """ organization, project = resolve_instance_and_project( detect=detect, organization=organization, project=project) client = get_build_client(organization) build = client.get_build(build_id=id, project=project) if open: _open_pipeline_run(build, organization) return build
def pipeline_variable_list(pipeline_id=None, pipeline_name=None, organization=None, project=None, detect=None): """List the variables in a pipeline :param pipeline_id: Id of the pipeline. :type pipeline_id: int :param pipeline_name: Name of the pipeline. Ignored if --pipeline-id parameter is supplied. :type pipeline_name: str """ organization, project = resolve_instance_and_project( detect=detect, organization=organization, project=project) if pipeline_id is None and pipeline_name is None: raise ValueError( 'Either the --pipeline-id or --pipeline-name argument ' + 'must be supplied for this command.') pipeline_client = get_build_client(organization) if pipeline_id is None: pipeline_id = get_definition_id_from_name(pipeline_name, pipeline_client, project) # get pipeline definition pipeline_definition = pipeline_client.get_definition( definition_id=pipeline_id, project=project) return pipeline_definition.variables
def pipeline_list(name=None, top=None, organization=None, project=None, repository=None, query_order=None, repository_type=None, detect=None): """List pipelines. :param name: Limit results to pipelines with this name or starting with this name. Examples: "FabCI" or "Fab*" :type name: str :param top: Maximum number of pipelines to list. :type top: int :param query_order: Order of the results. :type query_order: str :param repository: Limit results to pipelines associated with this repository. :type repository: str :param detect: Automatically detect values for organization and project. Default is "on". :type detect: str :param repository_type: Limit results to pipelines associated with this repository type. It is mandatory to pass 'repository' argument along with this argument. :type repository_type: str """ organization, project = resolve_instance_and_project( detect=detect, organization=organization, project=project) client = get_build_client(organization) query_order = _resolve_query_order(query_order) if repository is not None: if repository_type is None: repository_type = 'TfsGit' if repository_type.lower() == 'tfsgit': repository = _resolve_repository_as_id(repository, organization, project) if repository is None: raise ValueError("Could not find a repository with name '{}', in project '{}'." .format(repository, project)) definition_references = client.get_definitions(project=project, name=name, repository_id=repository, repository_type=repository_type, top=top, query_order=query_order) return definition_references
def build_definition_show(id=None, name=None, open=False, organization=None, project=None, # pylint: disable=redefined-builtin detect=None): """Get the details of a build definition. :param id: ID of the definition. :type id: int :param name: Name of the definition. Ignored if --id is supplied. :type name: str :param open: Open the definition summary page in your web browser. :type open: bool :param organization: Azure Devops organization URL. Example: https://dev.azure.com/MyOrganizationName/ :type organization: str :param project: Name or ID of the team project. :type project: str :param detect: Automatically detect values for instance and project. Default is "on". :type detect: str :rtype: BuildDefinitionReference """ try: organization, project = resolve_instance_and_project( detect=detect, organization=organization, project=project) client = get_build_client(organization) if id is None: if name is not None: id = get_definition_id_from_name(name, client, project) else: raise ValueError("Either the --id argument or the --name argument must be supplied for this command.") build_definition = client.get_definition(definition_id=id, project=project) if open: _open_definition(build_definition, organization) return build_definition except VstsServiceError as ex: raise CLIError(ex)
def delete_build_tag(build_id, tag, organization=None, project=None, detect=None): """Delete a build tag. :param build_id: ID of the build. :type build_id: int :param tag: Tag to be deleted from the build. :type tag: str :param organization: Azure Devops organization URL. Example: https://dev.azure.com/MyOrganizationName/ :type organization: str :param project: Name or ID of the team project. :type project: str :param detect: Automatically detect instance and project. Default is "on". :type detect: str :rtype: list of str """ try: organization, project = resolve_instance_and_project( detect=detect, organization=organization, project=project) client = get_build_client(organization) tags = client.delete_build_tag(project=project, build_id=build_id, tag=tag) return tags except VstsServiceError as ex: raise CLIError(ex)
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. :type build_id: int :param tags: Tag(s) to be added to the build. [Comma seperated values] :type tags: str :param organization: Azure Devops organization URL. Example: https://dev.azure.com/MyOrganizationName/ :type organization: str :param project: Name or ID of the team project. :type project: str :param detect: Automatically detect instance and project. Default is "on". :type detect: str :rtype: list of str """ try: organization, project = resolve_instance_and_project( detect=detect, organization=organization, project=project) client = get_build_client(organization) tags = list(map(str, tags.split(','))) if len(tags) == 1: tags = client.add_build_tag(project=project, build_id=build_id, tag=tags[0]) else: tags = client.add_build_tags(tags=tags, project=project, build_id=build_id) return tags except VstsServiceError as ex: raise CLIError(ex)
def pipeline_run( id=None, branch=None, commit_id=None, name=None, open=False, variables=None, # pylint: disable=redefined-builtin folder_path=None, organization=None, project=None, detect=None): """ Queue (run) a pipeline. :param id: ID of the pipeline to queue. Required if --name is not supplied. :type id: int :param name: Name of the pipeline to queue. Ignored if --id is supplied. :type name: str :param branch: Name of the branch on which the pipeline run is to be queued. Example: refs/heads/master or master or refs/pull/1/merge or refs/tags/tag :type branch: str :param folder_path: Folder path of pipeline. Default is root level folder. :type folder_path: str :param variables: Space separated "name=value" pairs for the variables you would like to set. :type variables: [str] :param commit_id: Commit-id on which the pipeline run is to be queued. :type commit_id: str :param open: Open the pipeline results page in your web browser. :type open: bool :param detect: Automatically detect organization and project. Default is "on". :type detect: str """ organization, project = resolve_instance_and_project( detect=detect, organization=organization, project=project) if id is None and name is None: raise ValueError('Either the --id argument or the --name argument ' + 'must be supplied for this command.') client = get_build_client(organization) if id is None: id = get_definition_id_from_name(name, client, project, folder_path) definition_reference = DefinitionReference(id=id) branch = resolve_git_ref_heads(branch) build = Build(definition=definition_reference, source_branch=branch, source_version=commit_id) if variables is not None and variables: build.parameters = {} for variable in variables: separator_pos = variable.find('=') if separator_pos >= 0: build.parameters[ variable[:separator_pos]] = variable[separator_pos + 1:] else: raise ValueError( 'The --variables argument should consist of space separated "name=value" pairs.' ) queued_build = client.queue_build(build=build, project=project) if open: _open_pipeline_run(queued_build, organization) return queued_build
def build_definition_list(name=None, top=None, organization=None, project=None, repository=None, repository_type=None, detect=None): """List build definitions. :param name: Limit results to definitions with this name or starting with this name. Examples: "FabCI" or "Fab*" :type name: bool :param top: Maximum number of definitions to list. :type top: int :param organization: Azure Devops organization URL. Example: https://dev.azure.com/MyOrganizationName/ :type organization: str :param project: Name or ID of the team project. :type project: str :param repository: Limit results to definitions associated with this repository. :type repository: str :param detect: Automatically detect values for organization and project. Default is "on". :type detect: str :param repository_type: Limit results to definitions associated with this repository type. It is mandatory to pass 'repository' argument along with this argument. :type repository_type: str :rtype: [BuildDefinitionReference] """ try: organization, project, repository = resolve_instance_project_and_repo( detect=detect, organization=organization, project=project, repo=repository) client = get_build_client(organization) query_order = 'DefinitionNameAscending' repository_type = None if repository is not None: if repository_type is None: repository_type = 'TfsGit' if repository_type.lower() == 'tfsgit': resolved_repository = _resolve_repository_as_id( repository, organization, project) else: resolved_repository = repository if resolved_repository is None: raise ValueError( "Could not find a repository with name '{}', in project '{}'." .format(repository, project)) else: resolved_repository = None definition_references = client.get_definitions( project=project, name=name, repository_id=resolved_repository, repository_type=repository_type, top=top, query_order=query_order) return definition_references except VstsServiceError as ex: raise CLIError(ex)
def build_list(definition_ids=None, branch=None, organization=None, project=None, detect=None, top=None, result=None, status=None, reason=None, tags=None, requested_for=None): """List build results. :param definition_ids: IDs (space separated) of definitions to list builds for. :type definition_ids: list of int :param branch: Filter by builds for this branch. :type branch: str :param organization: Azure Devops organization URL. Example: https://dev.azure.com/MyOrganizationName/ :type organization: str :param project: Name or ID of the team project. :type project: str :param detect: Automatically detect organization and project. Default is "on". :type detect: str :param top: Maximum number of builds to list. :type top: int :param result: Limit to builds with this result. :type result: str :param status: Limit to builds with this status. :type status: str :param reason: Limit to builds with this reason. :type reason: str :param tags: Limit to builds with each of the specified tags. Space separated. :type tags: list of str :param requested_for: Limit to builds requested for this user or group. :type requested_for: str :rtype: :class:`<Build> <build.v4_0.models.Build>` """ try: organization, project = resolve_instance_and_project( detect=detect, organization=organization, project=project) client = get_build_client(organization) if definition_ids is not None and definition_ids: definition_ids = list(set(definition_ids)) # make distinct if tags is not None and tags: tags = list(set(tags)) # make distinct builds = client.get_builds(definitions=definition_ids, project=project, branch_name=resolve_git_ref_heads(branch), top=top, result_filter=result, status_filter=status, reason_filter=reason, tag_filters=tags, requested_for=resolve_identity_as_id( requested_for, organization)) return builds except VstsServiceError as ex: raise CLIError(ex)
def run_artifact_list(run_id, organization=None, project=None, detect=None): """ List artifacts associated with a run. :param run_id: ID of the run that the artifact is associated to. :type run_id: int """ organization, project = resolve_instance_and_project(detect=detect, organization=organization, project=project) client = get_build_client(organization) artifacts = client.get_artifacts(project=project, build_id=run_id) return artifacts
def get_build_tags(build_id, organization=None, project=None, detect=None): """Get tags for a build :param build_id: ID of the build. :type build_id: int :rtype: list of str """ organization, project = resolve_instance_and_project( detect=detect, organization=organization, project=project) client = get_build_client(organization) tags = client.get_build_tags(build_id=build_id, project=project) return tags
def pipeline_delete(id, organization=None, project=None, detect=None): # pylint: disable=redefined-builtin """Delete a pipeline. :param id: ID of the pipeline. :type id: int :param detect: Automatically detect instance and project. Default is "on". :type detect: str """ organization, project = resolve_instance_and_project( detect=detect, organization=organization, project=project) client = get_build_client(organization) build = client.delete_definition(definition_id=id, project=project) return build
def pipeline_run_list(pipeline_ids=None, branch=None, organization=None, project=None, detect=None, top=None, query_order=None, result=None, status=None, reason=None, tags=None, requested_for=None): """ List the pipeline runs in a project. :param pipeline_ids: IDs (space separated) of definitions to list builds for. For multiple pipeline ids: --pipeline-ids 1 2 :type pipeline_ids: list of int :param branch: Filter by builds for this branch. :type branch: str :param top: Maximum number of builds to list. :type top: int :param query_order: Order of pipeline runs. :type query_order: str :param result: Limit to builds with this result. :type result: str :param status: Limit to builds with this status. :type status: str :param reason: Limit to builds with this reason. :type reason: str :param tags: Limit to builds with each of the specified tags. Space separated. :type tags: list of str :param requested_for: Limit to builds requested for this user or group. :type requested_for: str """ organization, project = resolve_instance_and_project( detect=detect, organization=organization, project=project) client = get_build_client(organization) if pipeline_ids is not None and pipeline_ids: pipeline_ids = list(set(pipeline_ids)) # make distinct if tags is not None and tags: tags = list(set(tags)) # make distinct query_order = _resolve_runs_query_order(query_order) builds = client.get_builds(definitions=pipeline_ids, project=project, branch_name=resolve_git_ref_heads(branch), top=top, result_filter=result, status_filter=status, reason_filter=reason, tag_filters=tags, query_order=query_order, requested_for=resolve_identity_as_id( requested_for, organization)) return builds
def pipeline_run_get_tags(run_id, organization=None, project=None, detect=None): """ Get tags for a pipeline run. :param run_id: ID of the pipeline run. :type run_id: int :rtype: list of str """ organization, project = resolve_instance_and_project(detect=detect, organization=organization, project=project) client = get_build_client(organization) tags = client.get_build_tags(build_id=run_id, project=project) return tags
def pipeline_variable_add(name, pipeline_id=None, pipeline_name=None, value=None, allow_override=None, secret=None, organization=None, project=None, detect=None): """Add a variable to a pipeline :param pipeline_id: Id of the pipeline. :type pipeline_id: int :param pipeline_name: Name of the pipeline. Ignored if --pipeline-id parameter is supplied. :type pipeline_name: str :param allow_override: Indicates whether the value can be set at queue time. :type allow_override: bool :param secret: Indicates whether the variable's value is a secret. :type secret: bool :param name: Name of the variable. :type name: str :param value: Value of the variable. For secret variables, if --value parameter is not given, it will be picked from environment variable prefixed with AZURE_DEVOPS_EXT_PIPELINE_VAR_ or user will be prompted to enter it via standard input. e.g. A variable named `MySecret` can be input using environment variable AZURE_DEVOPS_EXT_PIPELINE_VAR_MySecret :type value: str """ organization, project = resolve_instance_and_project( detect=detect, organization=organization, project=project) if pipeline_id is None and pipeline_name is None: raise ValueError('Either the --pipeline-id or --pipeline-name argument ' + 'must be supplied for this command.') pipeline_client = get_build_client(organization) if pipeline_id is None: pipeline_id = get_definition_id_from_name(pipeline_name, pipeline_client, project) # get pipeline definition pipeline_definition = pipeline_client.get_definition(definition_id=pipeline_id, project=project) # Check if the variable already exists if pipeline_definition.variables: for key in pipeline_definition.variables.keys(): if key.lower() == name.lower(): raise CLIError( 'Variable \'{}\' already exists. ' 'Use `az pipelines variable update` command to update the key/value.'.format(key)) else: pipeline_definition.variables = {} # Add the variable to the definition from azext_devops.devops_sdk.v5_0.build.models import BuildDefinitionVariable if not value: if secret: value = _get_value_from_env_or_stdin(var_name=name) else: raise CLIError('--value is required as parameter for non secret variable.') pipeline_definition.variables[name] = BuildDefinitionVariable(allow_override=allow_override, is_secret=secret, value=value) updated_variables = pipeline_client.update_definition( project=project, definition_id=pipeline_id, definition=pipeline_definition).variables var_name, var_value = _case_insensitive_get(input_dict=updated_variables, search_key=name) return {var_name: var_value}
def pipeline_folder_delete(path, organization=None, project=None, detect=None): """ Delete a folder. :param path: Full path of the folder. :type path: str :param project: Name or ID of the team project. :type project: str :param detect: Automatically detect organization and project. Default is "on". :type detect: str """ organization, project = resolve_instance_and_project( detect=detect, organization=organization, project=project) client = get_build_client(organization) return client.delete_folder(path=path, project=project)
def delete_build_tag(build_id, tag, organization=None, project=None, detect=None): """Delete a build tag. :param build_id: ID of the build. :type build_id: int :param tag: Tag to be deleted from the build. :type tag: str :rtype: list of str """ organization, project = resolve_instance_and_project(detect=detect, organization=organization, project=project) client = get_build_client(organization) tags = client.delete_build_tag(project=project, build_id=build_id, tag=tag) return tags
def get_authorize_resource(res_id, res_type, organization, project): """ param id: Id of the resource to authorize param name: Name of the resource to authorize param type: Type of the resource to authorize param organization: Organization URL param project: Project Id """ client = get_build_client(organization=organization) resource = client.get_project_resources(project=project, id=res_id, type=res_type) if resource: return resource[0].authorized return None
def build_show(id, open=False, organization=None, project=None, detect=None): # pylint: disable=redefined-builtin """Get the details of a build. :param id: ID of the build. :type id: int :param open: Open the build results page in your web browser. :type open: bool :rtype: :class:`<Build> <build.v4_0.models.Build>` """ organization, project = resolve_instance_and_project( detect=detect, organization=organization, project=project) client = get_build_client(organization) build = client.get_build(build_id=id, project=project) if open: _open_build(build, organization) return build
def build_list(definition_ids=None, branch=None, organization=None, project=None, detect=None, top=None, result=None, status=None, reason=None, tags=None, requested_for=None): """List build results. :param definition_ids: IDs (space separated) of definitions to list builds for. :type definition_ids: list of int :param branch: Filter by builds for this branch. :type branch: str :param top: Maximum number of builds to list. :type top: int :param result: Limit to builds with this result. :type result: str :param status: Limit to builds with this status. :type status: str :param reason: Limit to builds with this reason. :type reason: str :param tags: Limit to builds with each of the specified tags. Space separated. :type tags: list of str :param requested_for: Limit to builds requested for this user or group. :type requested_for: str :rtype: :class:`<Build> <build.v4_0.models.Build>` """ organization, project = resolve_instance_and_project( detect=detect, organization=organization, project=project) client = get_build_client(organization) if definition_ids is not None and definition_ids: definition_ids = list(set(definition_ids)) # make distinct if tags is not None and tags: tags = list(set(tags)) # make distinct builds = client.get_builds(definitions=definition_ids, project=project, branch_name=resolve_git_ref_heads(branch), top=top, result_filter=result, status_filter=status, reason_filter=reason, tag_filters=tags, requested_for=resolve_identity_as_id( requested_for, organization)) return builds
def pipeline_run_delete_tag(run_id, tag, organization=None, project=None, detect=None): """ (PREVIEW) Delete a pipeline run tag. :param run_id: ID of the pipeline run. :type run_id: int :param tag: Tag to be deleted from the pipeline run. :type tag: str :rtype: list of str """ organization, project = resolve_instance_and_project( detect=detect, organization=organization, project=project) client = get_build_client(organization) tags = client.delete_build_tag(project=project, build_id=run_id, tag=tag) return tags
def set_authorize_resource(authorized, res_id, name, res_type, organization, project): """ param authorized: Boolean value set to authorize or unauthorize resource param id: Id of the resource to authorize param name: Name of the resource to authorize param type: Type of the resource to authorize param organization: Organization URL param project: Project Id """ client = get_build_client(organization=organization) resources = [ DefinitionResourceReference(authorized=authorized, id=res_id, name=name, type=res_type) ] client.authorize_project_resources(resources=resources, project=project)