When extending the container template to allow scheduled pipelines in upstream context, we must ensure that all the existing rules defined by .base_job_template are preserved. Fortunately since the new rule for scheduled pipelines can come at the head of all other rules, not in the middle, we can just the obscure '!reference' syntax to pull in all the pre-existing rules as a single block. This fixes * stable branches using the wrong tag name in container images * pushes to forks unconditionally running container builds Fixes:8bec7b9874Signed-off-by: Daniel P. Berrangé <berrange@redhat.com> Tested-by: Michael Tokarev <mjt@tls.msk.ru> Fixes:8bec7b9874("gitlab: add a weekly container building job") Message-ID: <20260119135528.2738108-1-berrange@redhat.com> Signed-off-by: Thomas Huth <thuth@redhat.com> (cherry picked from commit 815567b4ea35176a8f92c5f25bfb335c1cac274e) Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
25 lines
1 KiB
YAML
25 lines
1 KiB
YAML
.container_job_template:
|
|
extends: .base_job_template
|
|
image: docker:latest
|
|
stage: containers
|
|
services:
|
|
- docker:dind
|
|
before_script:
|
|
- export TAG="$CI_REGISTRY_IMAGE/qemu/$NAME:$QEMU_CI_CONTAINER_TAG"
|
|
# Always ':latest' because we always use upstream as a common cache source
|
|
- export COMMON_TAG="$CI_REGISTRY/qemu-project/qemu/qemu/$NAME:latest"
|
|
- docker login $CI_REGISTRY -u "$CI_REGISTRY_USER" -p "$CI_REGISTRY_PASSWORD"
|
|
- until docker info; do sleep 1; done
|
|
script:
|
|
- echo "TAG:$TAG"
|
|
- echo "COMMON_TAG:$COMMON_TAG"
|
|
- docker build --tag "$TAG" --cache-from "$TAG" --cache-from "$COMMON_TAG"
|
|
--build-arg BUILDKIT_INLINE_CACHE=1
|
|
-f "tests/docker/dockerfiles/$NAME.docker" "."
|
|
- docker push "$TAG"
|
|
after_script:
|
|
- docker logout
|
|
rules:
|
|
# because we want to enable this for scheduled runs we also have to replicate the normal rules
|
|
- if: '$CI_PIPELINE_SOURCE == "schedule" && $CI_PROJECT_NAMESPACE == $QEMU_CI_UPSTREAM'
|
|
- !reference [.base_job_template, rules]
|