mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-26 03:31:05 +00:00
ci: Fix project URL when triggering cerbero pipelines
When merge request pipelines are triggered on the gstreamer namespace, CI_PROJECT_URL will be gitlab.[...]/gstreamer/gstreamer but we need to use gitlab.[...]/$USER/gstreamer because that's where the source branch is located. This exhibits as cerbero pipelines failing because it can't find the specified branch: https://gitlab.freedesktop.org/gstreamer/cerbero/-/pipelines/639379 Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/2761>
This commit is contained in:
parent
41bf3f6c1b
commit
885d4b84a5
1 changed files with 20 additions and 7 deletions
|
@ -39,15 +39,14 @@ if __name__ == "__main__":
|
||||||
job_token=os.environ.get('CI_JOB_TOKEN'))
|
job_token=os.environ.get('CI_JOB_TOKEN'))
|
||||||
|
|
||||||
cerbero = None
|
cerbero = None
|
||||||
|
cerbero_name = None
|
||||||
# We do not want to run on (often out of date) user upstream branch
|
# 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']:
|
if os.environ["CI_COMMIT_REF_NAME"] != os.environ['GST_UPSTREAM_BRANCH']:
|
||||||
try:
|
try:
|
||||||
user_cerbero_name = f'{os.environ["CI_PROJECT_NAMESPACE"]}/cerbero'
|
cerbero_name = f'{os.environ["CI_PROJECT_NAMESPACE"]}/cerbero'
|
||||||
cerbero = gl.projects.get(user_cerbero_name)
|
cerbero = gl.projects.get(cerbero_name)
|
||||||
if os.environ["CI_COMMIT_REF_NAME"] in [b.name for b in cerbero.branches.list()]:
|
if os.environ["CI_COMMIT_REF_NAME"] in [b.name for b in cerbero.branches.list()]:
|
||||||
cerbero_branch = os.environ["CI_COMMIT_REF_NAME"]
|
cerbero_branch = os.environ["CI_COMMIT_REF_NAME"]
|
||||||
fprint(
|
|
||||||
f"-> Triggering on branch {cerbero_branch} in {user_cerbero_name}\n")
|
|
||||||
else:
|
else:
|
||||||
# No branch with a same name on the user cerbero repo... trigger
|
# No branch with a same name on the user cerbero repo... trigger
|
||||||
# on upstream project
|
# on upstream project
|
||||||
|
@ -56,15 +55,29 @@ if __name__ == "__main__":
|
||||||
pass
|
pass
|
||||||
|
|
||||||
if cerbero is None:
|
if cerbero is None:
|
||||||
cerbero = gl.projects.get(CERBERO_PROJECT)
|
cerbero_name = CERBERO_PROJECT
|
||||||
|
cerbero = gl.projects.get(cerbero_name)
|
||||||
cerbero_branch = os.environ["GST_UPSTREAM_BRANCH"]
|
cerbero_branch = os.environ["GST_UPSTREAM_BRANCH"]
|
||||||
|
|
||||||
|
fprint(f"-> Triggering on branch {cerbero_branch} in {cerbero_name}\n")
|
||||||
|
|
||||||
|
# CI_PROJECT_URL is not necessarily the project where the branch we need to
|
||||||
|
# build resides, for instance merge request pipelines can be run on
|
||||||
|
# 'gstreamer' namespace. Fetch the branch name in the same way, just in
|
||||||
|
# case it breaks in the future.
|
||||||
|
if 'CI_MERGE_REQUEST_SOURCE_PROJECT_URL' in os.environ:
|
||||||
|
project_url = os.environ['CI_MERGE_REQUEST_SOURCE_PROJECT_URL']
|
||||||
|
project_branch = os.environ['CI_MERGE_REQUEST_SOURCE_BRANCH_NAME']
|
||||||
|
else:
|
||||||
|
project_url = os.environ['CI_PROJECT_URL']
|
||||||
|
project_branch = os.environ['CI_COMMIT_REF_NAME']
|
||||||
|
|
||||||
pipe = cerbero.trigger_pipeline(
|
pipe = cerbero.trigger_pipeline(
|
||||||
token=os.environ['CI_JOB_TOKEN'],
|
token=os.environ['CI_JOB_TOKEN'],
|
||||||
ref=cerbero_branch,
|
ref=cerbero_branch,
|
||||||
variables={
|
variables={
|
||||||
"CI_GSTREAMER_URL": os.environ["CI_PROJECT_URL"],
|
"CI_GSTREAMER_URL": project_url,
|
||||||
"CI_GSTREAMER_REF_NAME": os.environ["CI_COMMIT_REF_NAME"],
|
"CI_GSTREAMER_REF_NAME": project_branch,
|
||||||
# This tells cerbero CI that this is a pipeline started via the
|
# This tells cerbero CI that this is a pipeline started via the
|
||||||
# trigger API, which means it can use a deps cache instead of
|
# trigger API, which means it can use a deps cache instead of
|
||||||
# building from scratch.
|
# building from scratch.
|
||||||
|
|
Loading…
Reference in a new issue