mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-22 17:51:16 +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'
|
||||||
|
@ -36,13 +35,33 @@ def fprint(msg):
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
server = os.environ['CI_SERVER_URL']
|
server = os.environ['CI_SERVER_URL']
|
||||||
gl = gitlab.Gitlab(server,
|
gl = gitlab.Gitlab(server,
|
||||||
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_branch = os.environ["GST_UPSTREAM_BRANCH"]
|
||||||
|
|
||||||
cerbero = gl.projects.get(CERBERO_PROJECT)
|
|
||||||
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