From a750380925102dda54b0159a27adce3a7e5cf7db Mon Sep 17 00:00:00 2001 From: Tim Jaacks <tim.jaacks@seco.com> Date: Mon, 25 Sep 2023 12:20:57 +0200 Subject: [PATCH] Confluence: add supported hardware information --- build-pipeline-yocto.yml.jinja2 | 12 ++++++++++++ build-pipeline.yml | 11 +++++++++++ confluence-labels.txt.jinja2 | 5 +++++ confluence-page.xml.jinja2 | 10 ++++++++++ scripts/collect_release_information.py | 13 ++++++++----- 5 files changed, 46 insertions(+), 5 deletions(-) create mode 100644 confluence-labels.txt.jinja2 diff --git a/build-pipeline-yocto.yml.jinja2 b/build-pipeline-yocto.yml.jinja2 index 7427f91c..e23ed53b 100644 --- a/build-pipeline-yocto.yml.jinja2 +++ b/build-pipeline-yocto.yml.jinja2 @@ -69,6 +69,18 @@ build-{{ machine }}: # branch, because we don't always execute the full pipeline on the master branches. # In those cases the actual build job does not exist, which results in a 404 error. BUILD_ARTIFACTS: ${BUILD_ARTIFACTS_PREFIX}-{{ machine }} + after_script: + # FIXME: This is necessary because we're using an old build for the build simulation + # which does not export these variables, yet. Can be removed as soon as we switch to + # a newer release already containing these variables. + - source build.env + # yamllint disable-line rule:line-length +{%- if machine == "seco-mx6" %} + - export SUPPORTED_HARDWARE=" SANTARO, SANTOKA, SANTINO, SANTINO LT, SANTVEND, " +{%- elif machine == "seco-mx8mm" %} + - export SUPPORTED_HARDWARE=" TANARO, " +{%- endif %} + - !reference [.save_build_env] {% endif %} diff --git a/build-pipeline.yml b/build-pipeline.yml index e6396968..23c7b97e 100644 --- a/build-pipeline.yml +++ b/build-pipeline.yml @@ -127,6 +127,8 @@ workflow: - echo "DISTRO_RELEASE_ARTEFACTS='${DISTRO_RELEASE_ARTEFACTS}'" >> build.env # Install script location is needed in test job - echo "FNG_INSTALL_URL=${FNG_INSTALL_URL}" >> build.env + # Supported hardware is needed for Confluence release page + - echo "SUPPORTED_HARDWARE='${SUPPORTED_HARDWARE}'" >> build.env # -------------------------------------------------------------------------------------- # Stage: Infrastructure @@ -464,9 +466,13 @@ workflow: - .gitlab-ci/scripts/render_jinja2_template.py --template="${PAGE_TEMPLATE}" > confluence-page.xml + - .gitlab-ci/scripts/render_jinja2_template.py + --template=.gitlab-ci/confluence-labels.txt.jinja2 + > confluence-labels.txt artifacts: paths: - confluence-page.xml + - confluence-labels.txt .publish-confluence-page: extends: @@ -479,6 +485,10 @@ workflow: - generate-confluence-page - build-version script: + - LABEL_ARGS="" + - while IFS= read -r line; do + [ -n "$line" ] && LABEL_ARGS="${LABEL_ARGS} --label=$line"; + done < confluence-labels.txt - .gitlab-ci/scripts/confluence_create_or_update_page.py --username="${CONFLUENCE_USERNAME}" --token="${CONFLUENCE_TOKEN}" @@ -487,6 +497,7 @@ workflow: --page-name="${RELEASE_NAME}" --content-file=confluence-page.xml --label="os-release" + ${LABEL_ARGS} # -------------------------------------------------------------------------------------- diff --git a/confluence-labels.txt.jinja2 b/confluence-labels.txt.jinja2 new file mode 100644 index 00000000..6c0c300d --- /dev/null +++ b/confluence-labels.txt.jinja2 @@ -0,0 +1,5 @@ +{%- for hardware in SUPPORTED_HARDWARE.split(',') | sort %} +{%- if hardware | trim | length %} +{{ hardware | trim | lower | replace(" ", "-")}} +{%- endif %} +{%- endfor %} diff --git a/confluence-page.xml.jinja2 b/confluence-page.xml.jinja2 index c2645e35..642f4d82 100644 --- a/confluence-page.xml.jinja2 +++ b/confluence-page.xml.jinja2 @@ -23,6 +23,16 @@ {%- endfor %} </td> </tr> + <tr> + <th><b>Supported Hardware</b></th> + <td> + {%- for hardware in SUPPORTED_HARDWARE.split(',') | sort %} + {%- if hardware | trim | length %} + <p>{{ hardware | trim }}</p> + {%- endif %} + {%- endfor %} + </td> + </tr> <tr> <th><b>Documentation</b></th> <td> diff --git a/scripts/collect_release_information.py b/scripts/collect_release_information.py index c530cac9..b9251ccb 100755 --- a/scripts/collect_release_information.py +++ b/scripts/collect_release_information.py @@ -13,8 +13,8 @@ from download_job_artifacts import download_job_artifact from get_pipeline_jobs import get_pipeline_jobs -def get_deploy_variables( - gitlab: Gitlab, project: Project, deploy_jobs: list[ProjectPipelineJob] +def get_job_env_variables( + gitlab: Gitlab, project: Project, jobs: list[ProjectPipelineJob], env_file: str ): """Get a list of deploy variables from the deploy.env files from the given deploy jobs. If a variable is set to different values in different jobs, the values are @@ -30,9 +30,8 @@ def get_deploy_variables( Dictionary of deploy variables with 'name' and 'value' fields """ variables = {} - env_file = "deploy.env" - for job in deploy_jobs: + for job in jobs: with tempfile.NamedTemporaryFile() as target_file: print(f"Downloading file {env_file} from job {job.name}", file=sys.stderr) @@ -48,6 +47,7 @@ def get_deploy_variables( for line in lines: name, value = line.partition("=")[::2] + value = value.strip("'") variables[name] = ( f"{variables[name]}\n{value}" if name in variables and variables[name] != value @@ -141,12 +141,15 @@ def main(): gitlab = Gitlab(args.gitlab_url, private_token=args.token) project = common.get_project(gitlab, args.project) + jobs = get_pipeline_jobs(gitlab, project, args.pipeline, stage="Build") + variables = get_job_env_variables(gitlab, project, jobs, "build.env") + jobs = get_pipeline_jobs(gitlab, project, args.pipeline, stage=args.deploy_stage) successful_jobs = [job for job in jobs if job.status == "success"] if not successful_jobs: exit(f"ERROR: no successful jobs found in stage '{args.deploy_stage}'") - variables = get_deploy_variables(gitlab, project, successful_jobs) + variables |= get_job_env_variables(gitlab, project, successful_jobs, "deploy.env") files = get_deployed_files(gitlab, project, successful_jobs) -- GitLab