Skip to content
Snippets Groups Projects
Commit c16ae4ea authored by Tim Jaacks's avatar Tim Jaacks
Browse files

check_pipeline_status: add parameter for trigger source

parent d321e1f6
No related branches found
No related tags found
1 merge request!66check_pipeline_status: add parameter for trigger source
Pipeline #8481 passed with stages
in 4 minutes and 1 second
......@@ -9,11 +9,13 @@ from gitlab import Gitlab, GitlabGetError
from gitlab.v4.objects import Project
def check_pipeline_status(project: Project, commit):
def check_pipeline_status(project: Project, commit, source):
"""Get latest pipeline status for a given commit"""
# Find pipeline for commit
pipelines = project.pipelines.list(sha=commit, retry_transient_errors=True)
pipelines = project.pipelines.list(
sha=commit, source=source, retry_transient_errors=True
)
if not pipelines:
print("ERROR: no pipeline for commit '%s' found" % commit)
sys.exit(1)
......@@ -58,13 +60,21 @@ def main():
dest="commit",
required=True,
)
parser.add_argument(
"--source",
help="""source that triggered the pipeline""",
choices=["push", "merge_request_event"],
dest="source",
default="push",
required=False,
)
args, _ = parser.parse_known_args()
gitlab = Gitlab(args.gitlab_url, private_token=args.token)
project = common.get_project(gitlab, args.project)
status = check_pipeline_status(project, args.commit)
status = check_pipeline_status(project, args.commit, args.source)
# If we are running in a job environment and the upstream status is canceled,
# explicitly cancel this job as well
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment