Newer
Older
---
# --------------------------------------------------------------------------------------
# Global
# --------------------------------------------------------------------------------------
include:
- project: {{ CI_PROJECT_ROOT_NAMESPACE }}/yocto/infrastructure/gitlab-ci
ref: {{ GITLAB_CI_REVISION }}
file: common.yml
workflow:
rules:
- if: $CI_PIPELINE_SOURCE == "parent_pipeline"
stages:
- infrastructure
# --------------------------------------------------------------------------------------
# Generate job
# --------------------------------------------------------------------------------------
# Use one single job to generate multiple yaml files for the downstream pipelines.
# FIXME: This is only necessary due to a GitLab limitation:
# https://gitlab.com/gitlab-org/gitlab/-/issues/347469
# We work around this by generating manifest-integration-jobs.yml from a Jinja2 template
# and insert the trigger project via a Jinja2 variable.
# The issue is already fixed and will be released in GitLab 15.3:
# https://gitlab.com/gitlab-org/gitlab/-/merge_requests/92346
# As soon as we update to this version, we can get rid of the generate job and convert
# the Jinja2 template to a simple YAML file.
generate:
extends:
- .infrastructure
script:
# The job generation script implicitly passes the OS environment to the template, so
# that the template has access to all GitLab CI variables. Hence there is no need
# to explicitly pass any of them as command line arguments.
{% for integration in INTEGRATION.split('\n') %}
{% set SOURCE_BRANCH, TARGET_PROJECT, TARGET_BRANCH = integration.split(':') %}
{% if (CI_MERGE_REQUEST_TARGET_BRANCH_NAME is defined
and SOURCE_BRANCH == CI_MERGE_REQUEST_TARGET_BRANCH_NAME)
or SOURCE_BRANCH == CI_COMMIT_REF_NAME %}
- TARGET_PROJECT={{ TARGET_PROJECT }}
.gitlab-ci/scripts/generate_job_from_template.py
--template=.gitlab-ci/manifest-integration-jobs.yml.jinja2
> manifest-integration-jobs-{{ loop.index }}.yml
{% endfor %}
artifacts:
expire_in: 4 weeks
paths:
- manifest-integration-jobs-*.yml
# --------------------------------------------------------------------------------------
# Trigger jobs
# --------------------------------------------------------------------------------------
{% for integration in INTEGRATION.split('\n') %}
{% set SOURCE_BRANCH, TARGET_PROJECT, TARGET_BRANCH = integration.split(':') %}
{% if (CI_MERGE_REQUEST_TARGET_BRANCH_NAME is defined
and SOURCE_BRANCH == CI_MERGE_REQUEST_TARGET_BRANCH_NAME)
or SOURCE_BRANCH == CI_COMMIT_REF_NAME %}
{{ TARGET_PROJECT }}:{{ TARGET_BRANCH }}:
stage: infrastructure
needs:
- generate
variables:
SOURCE_BRANCH: {{ SOURCE_BRANCH }}
TARGET_PROJECT: {{ TARGET_PROJECT }}
TARGET_BRANCH: {{ TARGET_BRANCH }}
GITLAB_CI_REVISION: {{ GITLAB_CI_REVISION }}
MANIFEST_FILE: {{ MANIFEST_FILE }}
BB_RECIPE_NAME: {{ BB_RECIPE_NAME }}
trigger:
include:
# FIXME: Use these settings after switching from jinja2 to yaml (see above)
# project: '${CI_PROJECT_ROOT_NAMESPACE}/yocto/infrastructure/gitlab-ci'
# ref: ${GITLAB_CI_REVISION}
# file: manifest-integration-jobs.yml
artifact: manifest-integration-jobs-{{ loop.index }}.yml
job: generate
strategy: depend