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
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
# --------------------------------------------------------------------------------------
# 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(':') %}
- 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(':') %}
{{ TARGET_PROJECT }}:{{ TARGET_BRANCH }}:
stage: infrastructure
needs:
- generate
variables:
MASTER_BRANCH_PROJECT: {{ SOURCE_BRANCH }}
MANIFEST_PROJECT: {{ TARGET_PROJECT }}
MASTER_BRANCH_MANIFEST: {{ 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
{% endfor %}