mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-26 03:31:05 +00:00
ci: Trigger cerbero on user project if a branch with the same name exists there
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/2264>
This commit is contained in:
parent
f90916f4bb
commit
956270f3ab
1 changed files with 24 additions and 5 deletions
|
@ -8,7 +8,6 @@ import gitlab
|
||||||
CERBERO_PROJECT = 'gstreamer/cerbero'
|
CERBERO_PROJECT = 'gstreamer/cerbero'
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class Status:
|
class Status:
|
||||||
FAILED = 'failed'
|
FAILED = 'failed'
|
||||||
MANUAL = 'manual'
|
MANUAL = 'manual'
|
||||||
|
@ -39,10 +38,30 @@ if __name__ == "__main__":
|
||||||
private_token=os.environ.get('GITLAB_API_TOKEN'),
|
private_token=os.environ.get('GITLAB_API_TOKEN'),
|
||||||
job_token=os.environ.get('CI_JOB_TOKEN'))
|
job_token=os.environ.get('CI_JOB_TOKEN'))
|
||||||
|
|
||||||
|
cerbero = None
|
||||||
|
# We do not want to run on (often out of date) user upstream branch
|
||||||
|
if os.environ["CI_COMMIT_REF_NAME"] != os.environ['GST_UPSTREAM_BRANCH']:
|
||||||
|
try:
|
||||||
|
user_cerbero_name = f'{os.environ["CI_PROJECT_NAMESPACE"]}/cerbero'
|
||||||
|
cerbero = gl.projects.get(user_cerbero_name)
|
||||||
|
if os.environ["CI_COMMIT_REF_NAME"] in [b.name for b in cerbero.branches.list()]:
|
||||||
|
cerbero_branch = os.environ["CI_COMMIT_REF_NAME"]
|
||||||
|
fprint(
|
||||||
|
f"-> Triggering on branch {cerbero_branch} in {user_cerbero_name}\n")
|
||||||
|
else:
|
||||||
|
# No branch with a same name on the user cerbero repo... trigger
|
||||||
|
# on upstream project
|
||||||
|
cerbero = None
|
||||||
|
except gitlab.exceptions.GitlabGetError:
|
||||||
|
pass
|
||||||
|
|
||||||
|
if cerbero is None:
|
||||||
cerbero = gl.projects.get(CERBERO_PROJECT)
|
cerbero = gl.projects.get(CERBERO_PROJECT)
|
||||||
|
cerbero_branch = os.environ["GST_UPSTREAM_BRANCH"]
|
||||||
|
|
||||||
pipe = cerbero.trigger_pipeline(
|
pipe = cerbero.trigger_pipeline(
|
||||||
token=os.environ['CI_JOB_TOKEN'],
|
token=os.environ['CI_JOB_TOKEN'],
|
||||||
ref=os.environ["GST_UPSTREAM_BRANCH"],
|
ref=cerbero_branch,
|
||||||
variables={
|
variables={
|
||||||
"CI_GSTREAMER_URL": os.environ["CI_PROJECT_URL"],
|
"CI_GSTREAMER_URL": os.environ["CI_PROJECT_URL"],
|
||||||
"CI_GSTREAMER_REF_NAME": os.environ["CI_COMMIT_REF_NAME"],
|
"CI_GSTREAMER_REF_NAME": os.environ["CI_COMMIT_REF_NAME"],
|
||||||
|
|
Loading…
Reference in a new issue