Extract the container job template to a new file (container-template.yml) to be able to reuse it without having to run all the jobs included, which are mainly useful for mainstream CI.
Reviewed-by: Willian Rampazzo <willi...@redhat.com> Signed-off-by: Philippe Mathieu-Daudé <f4...@amsat.org> --- .gitlab-ci.d/container-template.yml | 22 ++++++++++++++++++++++ .gitlab-ci.d/containers.yml | 24 ++---------------------- 2 files changed, 24 insertions(+), 22 deletions(-) create mode 100644 .gitlab-ci.d/container-template.yml diff --git a/.gitlab-ci.d/container-template.yml b/.gitlab-ci.d/container-template.yml new file mode 100644 index 00000000000..9e3f3ae3c26 --- /dev/null +++ b/.gitlab-ci.d/container-template.yml @@ -0,0 +1,22 @@ +.container_job_template: + image: docker:stable + stage: containers + services: + - docker:dind + before_script: + - export TAG="$CI_REGISTRY_IMAGE/qemu/$NAME:latest" + - export COMMON_TAG="$CI_REGISTRY/qemu-project/qemu/$NAME:latest" + - apk add python3 + - docker info + - docker login $CI_REGISTRY -u "$CI_REGISTRY_USER" -p "$CI_REGISTRY_PASSWORD" + script: + - echo "TAG:$TAG" + - echo "COMMON_TAG:$COMMON_TAG" + - docker pull "$TAG" || docker pull "$COMMON_TAG" || true + - ./tests/docker/docker.py --engine docker build + -t "qemu/$NAME" -f "tests/docker/dockerfiles/$NAME.docker" + -r $CI_REGISTRY_IMAGE + - docker tag "qemu/$NAME" "$TAG" + - docker push "$TAG" + after_script: + - docker logout diff --git a/.gitlab-ci.d/containers.yml b/.gitlab-ci.d/containers.yml index 4ef76d1f54d..0bf4899df10 100644 --- a/.gitlab-ci.d/containers.yml +++ b/.gitlab-ci.d/containers.yml @@ -1,25 +1,5 @@ -.container_job_template: - image: docker:stable - stage: containers - services: - - docker:dind - before_script: - - export TAG="$CI_REGISTRY_IMAGE/qemu/$NAME:latest" - - export COMMON_TAG="$CI_REGISTRY/qemu-project/qemu/$NAME:latest" - - apk add python3 - - docker info - - docker login $CI_REGISTRY -u "$CI_REGISTRY_USER" -p "$CI_REGISTRY_PASSWORD" - script: - - echo "TAG:$TAG" - - echo "COMMON_TAG:$COMMON_TAG" - - docker pull "$TAG" || docker pull "$COMMON_TAG" || true - - ./tests/docker/docker.py --engine docker build - -t "qemu/$NAME" -f "tests/docker/dockerfiles/$NAME.docker" - -r $CI_REGISTRY_IMAGE - - docker tag "qemu/$NAME" "$TAG" - - docker push "$TAG" - after_script: - - docker logout +include: + - local: '/.gitlab-ci.d/container-template.yml' amd64-alpine-container: extends: .container_job_template -- 2.26.3