Loading .gitlab-ci.yml +154 −0 Original line number Diff line number Diff line Loading @@ -9,6 +9,7 @@ stages: - update_values - package_publish - release - nightly_check - nightly_deploy - nightly_workflows - nightly_result Loading Loading @@ -486,12 +487,118 @@ release_job: - '$CI_COMMIT_MESSAGE =~ /^release:\s/' nightly_check_images_job: stage: nightly_check tags: - hypo image: name: labs.etsi.org:5050/osl/hypo/code/org.etsi.osl.hypo.ops/cicd/integration.tests/docker:29.1.3 before_script: - docker info >/dev/null - | echo -n "$CI_REGISTRY_PASSWORD" | docker login \ --username "$CI_REGISTRY_USER" \ --password-stdin \ "$CI_REGISTRY" script: - | set -eu DIFFERENCES_FOUND=false echo "Checking whether nightly execution is required..." echo for IMAGE in $NIGHTLY_IMAGES; do DEV_IMAGE="${IMAGE}:dev-latest" LATEST_IMAGE="${IMAGE}:latest" echo "==============================================" echo "Image: $IMAGE" if ! docker pull "$DEV_IMAGE"; then echo "ERROR: Could not pull $DEV_IMAGE" >&2 exit 1 fi if ! docker pull "$LATEST_IMAGE"; then echo "ERROR: Could not pull $LATEST_IMAGE" >&2 exit 1 fi DEV_IMAGE_ID=$( docker image inspect \ --format '{{.Id}}' \ "$DEV_IMAGE" ) LATEST_IMAGE_ID=$( docker image inspect \ --format '{{.Id}}' \ "$LATEST_IMAGE" ) echo "dev-latest ID: $DEV_IMAGE_ID" echo "latest ID: $LATEST_IMAGE_ID" if [ "$DEV_IMAGE_ID" != "$LATEST_IMAGE_ID" ]; then echo "Result: DIFFERENT" DIFFERENCES_FOUND=true else echo "Result: SAME" fi docker image rm -f \ "$DEV_IMAGE" \ "$LATEST_IMAGE" \ >/dev/null 2>&1 || true done echo if [ "$DIFFERENCES_FOUND" = true ]; then echo "At least one image changed." echo "The nightly pipeline will run." echo "RUN_NIGHTLY=true" > nightly.env else echo "All dev-latest images are identical to latest." echo "The nightly deployment and workflows will be bypassed." echo "RUN_NIGHTLY=false" > nightly.env fi artifacts: reports: dotenv: nightly.env expire_in: 1 day rules: - if: '$CI_PIPELINE_SOURCE == "schedule"' when: on_success - when: never nightly_deploy_job: stage: nightly_deploy image: name: labs.etsi.org:5050/osl/hypo/code/org.etsi.osl.hypo.ops/cicd/integration.tests/python-argocd:3.9 pull_policy: [always, if-not-present] needs: - job: nightly_check_images_job artifacts: true before_script: - | if [ "${RUN_NIGHTLY:-false}" != "true" ]; then echo "No image differences. Bypassing $CI_JOB_NAME." exit 0 fi - mkdir -p /tmp/bin ~/.ssh - chmod 700 ~/.ssh - export PATH="/tmp/bin:$PATH" Loading Loading @@ -609,6 +716,12 @@ nightly_workflows_job: stage: nightly_workflows image: labs.etsi.org:5050/osl/hypo/code/org.etsi.osl.hypo.ops/cicd/integration.tests/maven:3.9-eclipse-temurin-17 before_script: - | if [ "${RUN_NIGHTLY:-false}" != "true" ]; then echo "No image differences. Bypassing $CI_JOB_NAME." exit 0 fi - apt-get update - apt-get install -y wget gnupg xvfb git Loading Loading @@ -653,6 +766,8 @@ nightly_workflows_job: needs: - job: nightly_deploy_job artifacts: false - job: nightly_check_images_job artifacts: true rules: - if: '$CI_PIPELINE_SOURCE == "schedule"' when: on_success Loading @@ -670,7 +785,15 @@ nightly_promote_images_job: needs: - job: nightly_workflows_job artifacts: false - job: nightly_check_images_job artifacts: true before_script: - | if [ "${RUN_NIGHTLY:-false}" != "true" ]; then echo "No image differences. Bypassing $CI_JOB_NAME." exit 0 fi - apk add --no-cache curl - docker info >/dev/null - | Loading Loading @@ -789,7 +912,16 @@ nightly_compare_failed_images_job: - job: nightly_workflows_job artifacts: false optional: true - job: nightly_check_images_job artifacts: true before_script: - | if [ "${RUN_NIGHTLY:-false}" != "true" ]; then echo "No image differences. Bypassing $CI_JOB_NAME." exit 0 fi # Required for querying the GitLab Container Registry API - apk add --no-cache curl jq Loading Loading @@ -1199,10 +1331,32 @@ nightly_cleanup_job: pull_policy: - always - if-not-present needs: - job: nightly_check_images_job artifacts: true - job: nightly_deploy_job artifacts: false optional: true - job: nightly_workflows_job artifacts: false optional: true - job: nightly_promote_images_job artifacts: false optional: true - job: nightly_compare_failed_images_job artifacts: false optional: true variables: NIGHTLY_HELM_RELEASE_NAME: "schedule" NIGHTLY_HELM_NAMESPACE: "schedule" before_script: - | if [ "${RUN_NIGHTLY:-false}" != "true" ]; then echo "No image differences. Bypassing $CI_JOB_NAME." exit 0 fi - mkdir -p ~/.ssh - chmod 700 ~/.ssh Loading Loading
.gitlab-ci.yml +154 −0 Original line number Diff line number Diff line Loading @@ -9,6 +9,7 @@ stages: - update_values - package_publish - release - nightly_check - nightly_deploy - nightly_workflows - nightly_result Loading Loading @@ -486,12 +487,118 @@ release_job: - '$CI_COMMIT_MESSAGE =~ /^release:\s/' nightly_check_images_job: stage: nightly_check tags: - hypo image: name: labs.etsi.org:5050/osl/hypo/code/org.etsi.osl.hypo.ops/cicd/integration.tests/docker:29.1.3 before_script: - docker info >/dev/null - | echo -n "$CI_REGISTRY_PASSWORD" | docker login \ --username "$CI_REGISTRY_USER" \ --password-stdin \ "$CI_REGISTRY" script: - | set -eu DIFFERENCES_FOUND=false echo "Checking whether nightly execution is required..." echo for IMAGE in $NIGHTLY_IMAGES; do DEV_IMAGE="${IMAGE}:dev-latest" LATEST_IMAGE="${IMAGE}:latest" echo "==============================================" echo "Image: $IMAGE" if ! docker pull "$DEV_IMAGE"; then echo "ERROR: Could not pull $DEV_IMAGE" >&2 exit 1 fi if ! docker pull "$LATEST_IMAGE"; then echo "ERROR: Could not pull $LATEST_IMAGE" >&2 exit 1 fi DEV_IMAGE_ID=$( docker image inspect \ --format '{{.Id}}' \ "$DEV_IMAGE" ) LATEST_IMAGE_ID=$( docker image inspect \ --format '{{.Id}}' \ "$LATEST_IMAGE" ) echo "dev-latest ID: $DEV_IMAGE_ID" echo "latest ID: $LATEST_IMAGE_ID" if [ "$DEV_IMAGE_ID" != "$LATEST_IMAGE_ID" ]; then echo "Result: DIFFERENT" DIFFERENCES_FOUND=true else echo "Result: SAME" fi docker image rm -f \ "$DEV_IMAGE" \ "$LATEST_IMAGE" \ >/dev/null 2>&1 || true done echo if [ "$DIFFERENCES_FOUND" = true ]; then echo "At least one image changed." echo "The nightly pipeline will run." echo "RUN_NIGHTLY=true" > nightly.env else echo "All dev-latest images are identical to latest." echo "The nightly deployment and workflows will be bypassed." echo "RUN_NIGHTLY=false" > nightly.env fi artifacts: reports: dotenv: nightly.env expire_in: 1 day rules: - if: '$CI_PIPELINE_SOURCE == "schedule"' when: on_success - when: never nightly_deploy_job: stage: nightly_deploy image: name: labs.etsi.org:5050/osl/hypo/code/org.etsi.osl.hypo.ops/cicd/integration.tests/python-argocd:3.9 pull_policy: [always, if-not-present] needs: - job: nightly_check_images_job artifacts: true before_script: - | if [ "${RUN_NIGHTLY:-false}" != "true" ]; then echo "No image differences. Bypassing $CI_JOB_NAME." exit 0 fi - mkdir -p /tmp/bin ~/.ssh - chmod 700 ~/.ssh - export PATH="/tmp/bin:$PATH" Loading Loading @@ -609,6 +716,12 @@ nightly_workflows_job: stage: nightly_workflows image: labs.etsi.org:5050/osl/hypo/code/org.etsi.osl.hypo.ops/cicd/integration.tests/maven:3.9-eclipse-temurin-17 before_script: - | if [ "${RUN_NIGHTLY:-false}" != "true" ]; then echo "No image differences. Bypassing $CI_JOB_NAME." exit 0 fi - apt-get update - apt-get install -y wget gnupg xvfb git Loading Loading @@ -653,6 +766,8 @@ nightly_workflows_job: needs: - job: nightly_deploy_job artifacts: false - job: nightly_check_images_job artifacts: true rules: - if: '$CI_PIPELINE_SOURCE == "schedule"' when: on_success Loading @@ -670,7 +785,15 @@ nightly_promote_images_job: needs: - job: nightly_workflows_job artifacts: false - job: nightly_check_images_job artifacts: true before_script: - | if [ "${RUN_NIGHTLY:-false}" != "true" ]; then echo "No image differences. Bypassing $CI_JOB_NAME." exit 0 fi - apk add --no-cache curl - docker info >/dev/null - | Loading Loading @@ -789,7 +912,16 @@ nightly_compare_failed_images_job: - job: nightly_workflows_job artifacts: false optional: true - job: nightly_check_images_job artifacts: true before_script: - | if [ "${RUN_NIGHTLY:-false}" != "true" ]; then echo "No image differences. Bypassing $CI_JOB_NAME." exit 0 fi # Required for querying the GitLab Container Registry API - apk add --no-cache curl jq Loading Loading @@ -1199,10 +1331,32 @@ nightly_cleanup_job: pull_policy: - always - if-not-present needs: - job: nightly_check_images_job artifacts: true - job: nightly_deploy_job artifacts: false optional: true - job: nightly_workflows_job artifacts: false optional: true - job: nightly_promote_images_job artifacts: false optional: true - job: nightly_compare_failed_images_job artifacts: false optional: true variables: NIGHTLY_HELM_RELEASE_NAME: "schedule" NIGHTLY_HELM_NAMESPACE: "schedule" before_script: - | if [ "${RUN_NIGHTLY:-false}" != "true" ]; then echo "No image differences. Bypassing $CI_JOB_NAME." exit 0 fi - mkdir -p ~/.ssh - chmod 700 ~/.ssh Loading