From 08d03b91a8680f30c23cff24f6f4be43d326636f Mon Sep 17 00:00:00 2001 From: Kevin Daudt Date: Tue, 26 Nov 2024 19:39:30 +0000 Subject: [PATCH] ci: use dynamic downstream pipelines This gives us more flexibiity with regards to the job configuration. One job generates the job configuration which then triggers a downstream pipeline. --- .gitlab-ci.yml | 30 ++++++++++++++++++++++++++++-- .gitlab/job-config.yaml | 0 2 files changed, 28 insertions(+), 2 deletions(-) create mode 100644 .gitlab/job-config.yaml diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 00d9f8849ee..3f7d0fbbba9 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -7,10 +7,10 @@ variables: GIT_DEPTH: "500" REGISTRY: registry.alpinelinux.org -# only rune pipelines for merge requests or when tags are pushed (for triggers) workflow: rules: - if: $CI_PIPELINE_SOURCE == "merge_request_event" + - if: $CI_PIPELINE_SOURCE == "pipeline" || $CI_PIPELINE_SOURCE == "parent_pipeline" - if: $CI_COMMIT_TAG lint: @@ -26,6 +26,32 @@ lint: - docker-alpine - x86_64 +generate-build-jobs: + stage: verify + image: + name: $REGISTRY/alpine/infra/docker/alpine-gitlab-ci:latest + script: + - pipeline generate .gitlab-ci.yml .gitlab/job-config.yaml >.gitlab/build-jobs.yaml + artifacts: + paths: + - .gitlab/build-jobs.yaml + tags: + - docker-alpine + - x86_64 + rules: + - if: $CI_PIPELINE_SOURCE == "merge_request_event" + +build-jobs: + stage: verify + needs: + - generate-build-jobs + trigger: + include: + - artifact: .gitlab/build-jobs.yaml + job: generate-build-jobs + rules: + - if: $CI_PIPELINE_SOURCE == "merge_request_event" + .build: stage: verify image: @@ -41,7 +67,7 @@ lint: expire_in: 1 day when: always rules: - - if: $CI_PIPELINE_SOURCE == "merge_request_event" + - if: $CI_PIPELINE_SOURCE == "parent_pipeline" build-x86_64: extends: .build diff --git a/.gitlab/job-config.yaml b/.gitlab/job-config.yaml new file mode 100644 index 00000000000..e69de29bb2d