tasks/pipeline.py
def clean_running_pipelines(ctx, git_ref=DEFAULT_BRANCH, here=False, use_latest_sha=False, sha=None):
    """
    Fetch running pipelines on a target ref (+ optionally a git sha), and ask the user if they
    should be cancelled.
    """

    project_name = "DataDog/datadog-agent"
    gitlab = Gitlab(project_name=project_name, api_token=get_gitlab_token())
    gitlab.test_project_found()

    if here:
        git_ref = ctx.run("git rev-parse --abbrev-ref HEAD", hide=True).stdout.strip()

    print(f"Fetching running pipelines on {git_ref}")

    if not sha and use_latest_sha:
        sha = ctx.run(f"git rev-parse {git_ref}", hide=True).stdout.strip()
        print(f"Git sha not provided, using the one {git_ref} currently points to: {sha}")
    elif not sha:
        print(f"Git sha not provided, fetching all running pipelines on {git_ref}")

    pipelines = get_running_pipelines_on_same_ref(gitlab, git_ref, sha)

    print(
        f"Found {len(pipelines)} running pipeline(s) matching the request.",
        "They are ordered from the newest one to the oldest one.\n",
        sep='\n',
    )
    cancel_pipelines_with_confirmation(gitlab, pipelines)

    Fetch running pipelines on a target ref (+ optionally a git sha), and ask the user if they
    should be cancelled.
    
Fetch running pipelines on a target ref (+ optionally a git sha), and ask the user if they
should be cancelled.
Fetch running pipelines on a target ref ( + optionally a git sha ) and ask the user if they should be cancelled .
def clean_running_pipelines(ctx, git_ref=DEFAULT_BRANCH, here=False, use_latest_sha=False, sha=None):
    project_name = "DataDog/datadog-agent"
    gitlab = Gitlab(project_name=project_name, api_token=get_gitlab_token())
    gitlab.test_project_found()
    if here:
        git_ref = ctx.run("git rev-parse --abbrev-ref HEAD", hide=True).stdout.strip()
    print(f"Fetching running pipelines on {git_ref}")
    if not sha and use_latest_sha:
        sha = ctx.run(f"git rev-parse {git_ref}", hide=True).stdout.strip()
        print(f"Git sha not provided, using the one {git_ref} currently points to: {sha}")
    elif not sha:
        print(f"Git sha not provided, fetching all running pipelines on {git_ref}")
    pipelines = get_running_pipelines_on_same_ref(gitlab, git_ref, sha)
    print(
        f"Found {len(pipelines)} running pipeline(s) matching the request.",
        "They are ordered from the newest one to the oldest one.\n",
        sep='\n',
    )
    cancel_pipelines_with_confirmation(gitlab, pipelines)
def clean_running_pipelines ( ctx , git_ref = DEFAULT_BRANCH , here = False , use_latest_sha = False , sha = None ) : project_name = "DataDog/datadog-agent" gitlab = Gitlab ( project_name = project_name , api_token = get_gitlab_token ( ) ) gitlab . test_project_found ( ) if here : git_ref = ctx . run ( "git rev-parse --abbrev-ref HEAD" , hide = True ) . stdout . strip ( ) print ( f"Fetching running pipelines on {git_ref}" ) if not sha and use_latest_sha : sha = ctx . run ( f"git rev-parse {git_ref}" , hide = True ) . stdout . strip ( ) print ( f"Git sha not provided, using the one {git_ref} currently points to: {sha}" ) elif not sha : print ( f"Git sha not provided, fetching all running pipelines on {git_ref}" ) pipelines = get_running_pipelines_on_same_ref ( gitlab , git_ref , sha ) print ( f"Found {len(pipelines)} running pipeline(s) matching the request." , "They are ordered from the newest one to the oldest one.\n" , sep = '\n' , ) cancel_pipelines_with_confirmation ( gitlab , pipelines )
Fetch running pipelines on a target ref (+ optionally a git sha), and ask the user if they
should be cancelled.
Fetch running pipelines on a target ref ( + optionally a git sha ) and ask the user if they should be cancelled .
"""
    Fetch running pipelines on a target ref (+ optionally a git sha), and ask the user if they
    should be cancelled.
    """
ctx
git_ref
here
use_latest_sha
sha