From 7501c731f7bc4c25010da207a32d28f98cbec020 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dylan=20A=C3=AFssi?= <dylan.aissi@collabora.com> Date: Thu, 18 Jul 2024 14:37:46 +0200 Subject: [PATCH] Add variables to select which part (build dashboard or trigger) to include in the pipeline MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Dylan Aïssi <dylan.aissi@collabora.com> --- .gitlab-ci.yml | 18 ++++++++++++++++++ .gitlab-ci/trigger-jobs.yml | 7 ++++++- templates/index.html.jinja2 | 6 +++--- 3 files changed, 27 insertions(+), 4 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 61f89f2..55d7c9b 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -78,10 +78,28 @@ variables: options: - "yes" - "no" + SKIP_BUILD_DASHBOARD: + description: | + Set to yes to skip jobs building the dashboard. + value: "" + options: + - "" + - "yes" + SKIP_TRIGGER_JOBS: + description: | + Set to yes to skip jobs triggering gitlab-rulez and trigger-updates. + value: "" + options: + - "" + - "yes" include: - local: .gitlab-ci/dashboard.yml + rules: + - if: '$SKIP_BUILD_DASHBOARD != "yes"' - local: .gitlab-ci/trigger-jobs.yml + rules: + - if: '$SKIP_TRIGGER_JOBS != "yes"' stages: - lint diff --git a/.gitlab-ci/trigger-jobs.yml b/.gitlab-ci/trigger-jobs.yml index 1ba32bb..9313165 100644 --- a/.gitlab-ci/trigger-jobs.yml +++ b/.gitlab-ci/trigger-jobs.yml @@ -17,8 +17,13 @@ trigger-updates: JOB_ID=${TRIGGER_FROM_JOB##*/} JOB_API_URL=$CI_API_V4_URL/projects/$CI_PROJECT_ID/jobs/$JOB_ID/ wget --header "JOB-TOKEN: $CI_JOB_TOKEN" "$JOB_API_URL/artifacts/public/packaging.json" - else + elif [ -e public/packaging.json ] + then + echo "Using public/packaging.json to define updatable packages" cp public/packaging.json . + else + echo "🛑 packaging.json is unavailable, please define TRIGGER_FROM_JOB or set INCLUDE_BUILD_DASHBOARD to yes" + exit 1 fi - | if [ -z "$TRIGGER_UPDATES" ] diff --git a/templates/index.html.jinja2 b/templates/index.html.jinja2 index 83370e3..0355e1d 100644 --- a/templates/index.html.jinja2 +++ b/templates/index.html.jinja2 @@ -193,18 +193,18 @@ <ul class="list-inline mr-auto"> <a class="btn btn-primary {{'disabled' if not summary.wrong_settings_count }}" title="Apply default settings to packages repositories" - href="{{- meta.new_pipeline_url -}}&var[TRIGGER_GITLAB_RULEZ]=apply + href="{{- meta.new_pipeline_url -}}&var[TRIGGER_GITLAB_RULEZ]=apply&var[INCLUDE_BUILD_DASHBOARD]=no ">Run gitlab-rulez</a> <a class="btn btn-primary {{'disabled' if not summary.total_updates_count }}" title="Trigger pipelines importing updates" - href="{{- meta.new_pipeline_url -}}&var[TRIGGER_UPDATES]=* + href="{{- meta.new_pipeline_url -}}&var[TRIGGER_UPDATES]=*&var[INCLUDE_BUILD_DASHBOARD]=no {%- if meta.current_job_url -%} &var[TRIGGER_FROM_JOB]={{- meta.current_job_url -}} {%- endif -%} ">Update all</a> <a class="btn btn-danger {{'disabled' if not summary.update_errors_count }}" title="Trigger pipelines importing security updates" - href="{{- meta.new_pipeline_url -}}&var[TRIGGER_UPDATES]=*&var[TRIGGER_SECURITY_UPDATES]=1 + href="{{- meta.new_pipeline_url -}}&var[TRIGGER_UPDATES]=*&var[TRIGGER_SECURITY_UPDATES]=1&var[INCLUDE_BUILD_DASHBOARD]=no {%- if meta.current_job_url -%} &var[TRIGGER_FROM_JOB]={{- meta.current_job_url -}} {%- endif -%} -- GitLab