Skip to content
Snippets Groups Projects
Select Git revision
  • a0964eb1870b7c397272def44d3a36332b00260f
  • master default protected
  • feature_bash_completion
3 results

.gitlab-ci.yml

Blame
  • .gitlab-ci.yml 3.51 KiB
    variables:
      DOCKERFILE_DEB: "${CI_PROJECT_DIR}/gitlab-ci/Dockerfile_DEB"
      IMAGE_TARGET_DEB: "${CI_REGISTRY_IMAGE}/debian12_validate_workflows_build_env"
    
    stages:          # List of stages for jobs, and their order of execution
      - build
      - test
      - packaging
    
    .build-env-job:
      stage: build
      timeout: 10m
      tags:
        - "docker"
      image:
        # Use Kaniko base image to build a Docker image to use as the base image for later jobs.
        name: gcr.io/kaniko-project/executor:debug
        entrypoint: [""]
      # Do not run the before_script tasks here, they wouldn't be included in the Docker image. Instead, provide an empty list of tasks.
      before_script: []
      # docu: https://docs.gitlab.com/ee/ci/docker/using_kaniko.html, this is basically copy-pasted from there
      script:
        - mkdir -p /kaniko/.docker
        - echo "{\"auths\":{\"$CI_REGISTRY\":{\"auth\":\"$(printf "%s:%s" "$CI_REGISTRY_USER" "$CI_REGISTRY_PASSWORD" | base64 | tr -d '\n')\"},\"$(printf "%s" "$CI_DEPENDENCY_PROXY_SERVER" | cut -d':' -f1)\":{\"auth\":\"$(printf "%s:%s" "$CI_DEPENDENCY_PROXY_USER" "$CI_DEPENDENCY_PROXY_PASSWORD" | base64 | tr -d '\n')\"}}}" > /kaniko/.docker/config.json
        # In this task, Kaniko executor is called to build the Image based on the Dockerfile provided with "--dockerfile".
        - echo "CI_PROJECT_DIR=${CI_PROJECT_DIR}"
        - >-
          /kaniko/executor
          --context "${CI_PROJECT_DIR}"
          --dockerfile "${DOCKERFILE}"
          --destination "${IMAGE_TARGET}:latest"
          --build-arg "GITDIR=${CI_PROJECT_DIR}"
          --cache=true
          --cache-repo=${CI_REGISTRY_IMAGE}
          --cache-copy-layers=true
          --snapshotMode=redo
          --use-new-run
          --ignore-var-run
    
    build-deb-env-job:
      extends: .build-env-job
      variables:
        DOCKERFILE: ${DOCKERFILE_DEB}
        IMAGE_TARGET: ${IMAGE_TARGET_DEB}
    
    test-in-debian-job:   # This job runs in the test stage.
      stage: test    # It only starts when the job in the build stage completes successfully.
      timeout: 5m
      tags:
        - "docker"
      image:
        name: "${IMAGE_TARGET_DEB}:latest"
      script:
        - shellcheck --color=always --shell=bash --enable=all --exclude=SC2317 "src/usr/local/bin/validate_workflow.sh"
    
    packaging-deb-job:
      stage: packaging
      timeout: 5m
      image:
        name: "${IMAGE_TARGET_DEB}:latest"
      tags:
        - "docker"
      script:
        # HINT: current working dir == '/builds/digital-preservation/validate_workflows' as root
        # retrieve version infos
        - REVISION="1"
        - BRANCH="$(([ -z "${CI_COMMIT_BRANCH}" ] && echo ${CI_COMMIT_TAG} || echo ${CI_COMMIT_BRANCH}) | sed "s#[^A-Za-z0-9\.~+-]##g")" # use tag name in tag pipelines, filter characters based on https://www.debian.org/doc/debian-policy/ch-controlfields.html#s-f-version
        - VERSION="$(git rev-list HEAD --count)-${BRANCH}"
        - ARCHITECTURE="all"
        # create build dir structure