Skip to content
Snippets Groups Projects
Commit d8e8ab74 authored by Lorenzo Pagliai's avatar Lorenzo Pagliai
Browse files

[BSP][RETRIGGER] Retrigger pipelines for BSP MRs

Every time a BSP related MR is merged, the SRCREV.conf file in the
corresponding meta-layer is updated and all other integration MRs in
that meta-layer can no longer be merged due to conflicts. For this
reason we add this steps every time a BSP related MR is merged:
* Search for all open MRs in the same BSP group of the project on which
the MR occurred.
* Retrigger the pipelines for all these MRs, that in turn updates the
integration branches in the meta-layer.
* All the integration MRs in the meta-layer are now mergeable so that if
two or more MRs are merged (tipically U-Boot and Kernel MRs are merged
almost at the same time) no conflict are expected to occur.
* Moreover, this procedure allows to have an integration MR in the
meta-layer always updated with the latest BSP version in the main
branch.

To make this work we also need to change the retrigger job, avoiding the
possibility to run 'check' jobs that are already running and that would
throw an error.
parent 32cf1f7a
No related branches found
No related tags found
No related merge requests found
......@@ -19,6 +19,42 @@ critical_error = (
" 2. examine why this has happened and fix it in the CI pipeline"
)
#Function necessary to retrigger the integration pipelines on the BSP
def retrigger_bsp_pipelines(
gl, group_name, ci_project
):
if "nxp" in ci_project:
bsp_group = group_name + "/nxp"
elif "rockchip" in ci_project:
bsp_group = group_name + "/rockchip"
else:
print("No valid BSP vendor found, retriggering all BSP projects")
bsp_group = group_name
print(f"This is the BSP group: {bsp_group}")
# Find the group
group = gl.groups.get(bsp_group)
# Get all projects within the BSP group
projects = group.projects.list(include_subgroups=True, all=True)
for project in projects:
print(f"Checking project: {project.name}")
repo = gl.projects.get(project.id)
# Get open merge requests
open_mrs = repo.mergerequests.list(state='opened')
# Retrigger pipeline execution for all open MRs
for mr in open_mrs:
print(f"Running pipeline for MR: {mr.title}")
pipeline = mr.pipelines.create()
if pipeline:
print(f"Pipeline created with ID: {pipeline.id}")
else:
print("Pipeline creation failed.")
sys.exit(1)
def get_source_integration_requests(
project, state=None, target_branch=None, commit=None
......@@ -188,6 +224,12 @@ def main():
dest="recipe_name",
required=True,
)
parser.add_argument(
"--bsp-group",
help="""Group containing all BSP projects""",
dest="bsp_group",
required=True,
)
parser.add_argument(
"--rebase",
help="""attempt to automatically rebase merge request if necessary""",
......@@ -237,6 +279,8 @@ def main():
else:
sys.exit(1)
# Retrigger all necessary pipeline in the BSP group
retrigger_bsp_pipelines(gitlab, args.bsp_group, args.project)
if __name__ == "__main__":
main()
......@@ -49,15 +49,17 @@ def retrigger_pipeline_jobs(
if job.status not in status_list:
return jobs
# Retrigger job
job.retry()
print("Retrigger job '%s' in %s:" % (job_name, pipeline.web_url))
job = project.jobs.get(job.id, retry_transient_errors=True)
print(job.web_url)
jobs.append(job)
return jobs
# Retrigger job only if it is not in 'running' status,
# otherwise an error will be thrown (403 Forbidden -
# Job is not retryable)
if "running" not in job.status:
job.retry()
print("Retrigger job '%s' in %s:" % (job_name, pipeline.web_url))
job = project.jobs.get(job.id, retry_transient_errors=True)
print(job.web_url)
jobs.append(job)
return job
def main():
parser = argparse.ArgumentParser()
......
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