diff options
author | Thibault Saunier <tsaunier@igalia.com> | 2021-09-27 19:37:18 -0300 |
---|---|---|
committer | Thibault Saunier <tsaunier@igalia.com> | 2021-09-28 10:58:25 -0300 |
commit | 37d7e9a22d6501b432b3fa6dea361a61c77124a2 (patch) | |
tree | 1f2b0608e74498f1e54b1a4de5ca9d855555ea37 /ci | |
parent | ef0594683787398d0c1b84461262bc514224270e (diff) | |
download | gstreamer-37d7e9a22d6501b432b3fa6dea361a61c77124a2.tar.gz |
ci: Wait for cerbero pipeline to finish
So we are sure the pipeline is marked as failed if the cerbero sub pipeline fails
See https://gitlab.com/gitlab-org/gitlab/-/issues/341737 for details
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/946>
Diffstat (limited to 'ci')
-rwxr-xr-x | ci/gitlab/trigger_cerbero_pipeline.py | 59 |
1 files changed, 59 insertions, 0 deletions
diff --git a/ci/gitlab/trigger_cerbero_pipeline.py b/ci/gitlab/trigger_cerbero_pipeline.py new file mode 100755 index 0000000000..5e89135da4 --- /dev/null +++ b/ci/gitlab/trigger_cerbero_pipeline.py @@ -0,0 +1,59 @@ +#!/usr/bin/python3 + +import time +import os +import sys +import gitlab + +CERBERO_ID = 1340 + +class Status: + FAILED = 'failed' + MANUAL = 'manual' + CANCELED = 'canceled' + SUCCESS = 'success' + SKIPPED = 'skipped' + CREATED = 'created' + + @classmethod + def is_finished(cls, state): + return state in [ + cls.FAILED, + cls.MANUAL, + cls.CANCELED, + cls.SUCCESS, + cls.SKIPPED, + ] + + +def fprint(msg): + print(msg, end="") + sys.stdout.flush() + +if __name__ == "__main__": + gl = gitlab.Gitlab( + "https://gitlab.freedesktop.org/", + private_token=os.environ.get('GITLAB_API_TOKEN'), + job_token=os.environ.get('CI_JOB_TOKEN') + ) + + cerbero = gl.projects.get(CERBERO_ID) + pipe = cerbero.trigger_pipeline( + token=os.environ['CI_JOB_TOKEN'], + ref=os.environ["UPSTREAM_BRANCH"], + variables={ + "CI_GSTREAMER_URL": os.environ["CI_PROJECT_URL"], + "CI_GSTREAMER_REF_NAME": os.environ["CI_COMMIT_REF_NAME"], + } + ) + + fprint(f'Cerbero pipeline running at {pipe.web_url} ') + while True: + time.sleep(15) + pipe.refresh() + if Status.is_finished(pipe.status): + fprint(f": {pipe.status}\n") + sys.exit(0 if pipe.status == Status.SUCCESS else 1) + else: + fprint(".") + |