Skip to content
Snippets Groups Projects
Unverified Commit 2ac52a83 authored by Andrej Shadura's avatar Andrej Shadura
Browse files

Add a template for image pipeline


To avoid repeating settings from image recipes, use a tiny Python script
to parse the original pipeline’s YAML definition and collect variables
into .env files to be sourced directly into the image building job’s
shell.

The original pipeline places the devroot tarball in a directory that
would otherwise not be accessible in this job, so we override it by
passing another -t devrootpack: argument to debos.

Signed-off-by: default avatarAndrej Shadura <andrew.shadura@collabora.co.uk>
parent c5d1c7fd
No related branches found
No related tags found
1 merge request!594Extend generate-pkg-centric-jobs.py to also generate image pipeline
Pipeline #671517 passed
.image-job-base:
image: $CI_REGISTRY/infrastructure/${OSNAME}-docker-images/${APERTIS_RELEASE}-image-builder
variables:
TEST_PATH: /tmp/tests
TEST_REPO_URL: https://gitlab-ci-token:${CI_JOB_TOKEN}@${CI_SERVER_HOST}/tests/${OSNAME}-test-cases.git
RECIPES_PATH: /tmp/recipes
RECIPES_REPO_URL: https://gitlab-ci-token:${CI_JOB_TOKEN}@${CI_SERVER_HOST}/infrastructure/${OSNAME}-image-recipes.git
stage: build
rules:
- when: on_success
script:
- JOB_GENERATOR_BRANCH=${JOB_GENERATOR_BRANCH:-${OSNAME}/${APERTIS_RELEASE}}
- git clone --depth "${GIT_DEPTH:-1}" -b "$JOB_GENERATOR_BRANCH" "${TEST_REPO_URL}" "$TEST_PATH"
- git clone --depth "${GIT_DEPTH:-1}" -b "${OSNAME}/${APERTIS_RELEASE}" "${RECIPES_REPO_URL}" "$RECIPES_PATH"
- >
"$TEST_PATH/extract-variables.py" < "$RECIPES_PATH/.gitlab-ci.yml" > image.env
- . image.env
- >
"$TEST_PATH/extract-variables.py" ".$TYPE" < "$RECIPES_PATH/.gitlab-ci.yml" > pipeline.env
- . pipeline.env
- |
if [[ ${debosarguments} =~ "-t devrootpack:" ]]
then
DEVROOT_ARCH=armhf
devroot_ospack_name="ospack_${RELEASE}-${DEVROOT_ARCH}-devroot_${BUILDID}"
wget --progress=dot:mega ${image_url_prefix_main}/daily/${RELEASE}/${BUILDID}/${DEVROOT_ARCH}/devroot/${devroot_ospack_name}.tar.gz
debosarguments="$debosarguments -t devrootpack:${devroot_ospack_name}.tar.gz"
fi
- ospack_name="ospack_${RELEASE}-${ARCH}-${TYPE}_${BUILDID}"
- wget --progress=dot:mega ${image_url_prefix_main}/daily/${RELEASE}/${BUILDID}/${ARCH}/${TYPE}/${ospack_name}.tar.gz
- local_repo_path=$PWD/package-repo/$ARCH
- echo ${debosarguments}
- debos ${debosarguments}
--show-boot
-t architecture:${ARCH}
-t osname:${OSNAME}
-t mirror:${mirror}
-t type:${TYPE}
-t sbc:${SBC}
-t ospack:${ospack_name}
-t suite:$RELEASE
-t timestamp:${PIPELINE_VERSION}
-t image:${IMAGE_NAME}
-t local_repo_path:${local_repo_path}
"$RECIPES_PATH/image-${BOARD}.yaml"
- echo "BUILT_IMAGE_URL=${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/jobs/${CI_JOB_ID}/artifacts/${IMAGE_NAME}.img" | tee -a build.env
artifacts:
reports:
dotenv: build.env
paths:
- '*.img.*'
expire_in: 1 day
#!/usr/bin/python3
# SPDX-License-Identifier: CC0-1.0
import sys
import yaml
d = yaml.safe_load(sys.stdin)
# walk the dict path
for k in sys.argv[1:]:
d = d.get(k, {})
# repr could work better than str, but it uses ' instead
# of " which blocks variable transclusion
print("\n".join(
k + '="' + str(v) + '"'
for k, v in d.get("variables", {}).items()
))
...@@ -91,8 +91,12 @@ actions: ...@@ -91,8 +91,12 @@ actions:
images: images:
image: image:
url: {{boot.image_url('gz')}} url: {{boot.image_url('gz')}}
headers:
JOB-TOKEN: {% raw %}{{job.CI_JOB_TOKEN}}{% endraw %}
bmap: bmap:
url: {{boot.image_url('bmap')}} url: {{boot.image_url('bmap')}}
headers:
JOB-TOKEN: {% raw %}{{job.CI_JOB_TOKEN}}{% endraw %}
uniquify: false uniquify: false
os: apertis os: apertis
writer: writer:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment