From c2f35badb0604c63d903222ea37596679774511b Mon Sep 17 00:00:00 2001 From: Jon Mayo Date: Thu, 31 Mar 2022 20:29:13 +0000 Subject: [PATCH] [ci] Skip external releases if associated OUT_REGISTRY value is empty. Allows CI/CD environment variables to quickly disable any release job derived from the .release:external template Template Usage: DRYRUN_RELEASE set to a value to echo docker and regctl commands in Makefile without running them (dry-run) SKIP_RELEASE set to a value to remove the job from the pipeline. CI/CD Usage: NGC_SKIP_RELEASE set to disable external release to NGC. DOCKERHUB_SKIP_RELEASE set to disable external release to DH. NGC_DRYRUN_RELEASE set to dry-run external release to NGC. DOCKERHUB_DRYRUN_RELEASE set to dry-run external release to DH. --- .common-ci.yml | 8 ++++++++ .nvidia-ci.yml | 4 ++++ 2 files changed, 12 insertions(+) diff --git a/.common-ci.yml b/.common-ci.yml index a9a51a8c..b71b4b6e 100644 --- a/.common-ci.yml +++ b/.common-ci.yml @@ -191,16 +191,24 @@ test-packaging: # Define an external release step that pushes an image to an external repository. # This includes a devlopment image off master. +# NOTE: job is skipped if OUT_REGISTRY is null or empty. Can be used to disable release(s) with CI/CD env. .release:external: extends: - .release rules: + - if: '$OUT_REGISTRY == null || $OUT_REGISTRY == "" || $SKIP_RELEASE' + when: never + - if: '$DRYRUN_RELEASE' + variables: + DOCKER: echo + REGCTL: echo - if: $CI_COMMIT_TAG variables: OUT_IMAGE_VERSION: "${CI_COMMIT_TAG}" - if: $CI_COMMIT_BRANCH == $RELEASE_DEVEL_BRANCH variables: OUT_IMAGE_VERSION: "${DEVEL_RELEASE_IMAGE_VERSION}" + - when: on_success # Define the release jobs release:staging-centos7: diff --git a/.nvidia-ci.yml b/.nvidia-ci.yml index 768b628d..1c21597a 100644 --- a/.nvidia-ci.yml +++ b/.nvidia-ci.yml @@ -231,6 +231,8 @@ scan-ubi8-arm64: OUT_REGISTRY_TOKEN: "${NGC_REGISTRY_TOKEN}" OUT_REGISTRY: "${NGC_REGISTRY}" OUT_IMAGE_NAME: "${NGC_REGISTRY_IMAGE}" + SKIP_RELEASE: "${NGC_SKIP_RELEASE}" + DRYRUN_RELEASE: "${NGC_DRYRUN_RELEASE}" .release:dockerhub: extends: @@ -240,6 +242,8 @@ scan-ubi8-arm64: OUT_REGISTRY_TOKEN: "${REGISTRY_TOKEN}" OUT_REGISTRY: "${DOCKERHUB_REGISTRY}" OUT_IMAGE_NAME: "${REGISTRY_IMAGE}" + SKIP_RELEASE: "${DOCKERHUB_SKIP_RELEASE}" + DRYRUN_RELEASE: "${DOCKERHUB_DRYRUN_RELEASE}" release:staging-ubuntu18.04: extends: