From 9aeabc204faefe37f1e1459d6154f770299ecf05 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9my=20Coutable?= <remy@rymai.me> Date: Thu, 19 Mar 2020 17:55:48 +0100 Subject: [PATCH] Make all jobs interruptible except the 'dont-interrupt-me' job MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Rémy Coutable <remy@rymai.me> --- .gitlab-ci.yml | 2 ++ .gitlab/ci/rules.gitlab-ci.yml | 11 +++++++++++ .gitlab/ci/setup.gitlab-ci.yml | 12 ++++++++++++ doc/development/pipelines.md | 9 +++++++++ 4 files changed, 34 insertions(+) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index be1818391ca0..be8b36128b28 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -16,6 +16,8 @@ stages: default: tags: - gitlab-org + # All jobs are interruptible by default + interruptible: true workflow: rules: diff --git a/.gitlab/ci/rules.gitlab-ci.yml b/.gitlab/ci/rules.gitlab-ci.yml index 6420e951a788..3dc09b9988ef 100644 --- a/.gitlab/ci/rules.gitlab-ci.yml +++ b/.gitlab/ci/rules.gitlab-ci.yml @@ -16,6 +16,9 @@ .if-master-refs: &if-master-refs if: '$CI_COMMIT_REF_NAME == "master"' +.if-auto-deploy-branches: &if-auto-deploy-branches + if: '$CI_COMMIT_BRANCH =~ /^\d+-\d+-auto-deploy-\d+$/' + .if-master-or-tag: &if-master-or-tag if: '$CI_COMMIT_REF_NAME == "master" || $CI_COMMIT_TAG' @@ -509,6 +512,14 @@ changes: *code-backstage-qa-patterns when: on_success +.setup:rules:dont-interrupt-me: + rules: + - <<: *if-master-or-tag + when: on_success + - <<: *if-auto-deploy-branches + when: on_success + - when: manual + .setup:rules:gitlab_git_test: rules: - <<: *if-default-refs diff --git a/.gitlab/ci/setup.gitlab-ci.yml b/.gitlab/ci/setup.gitlab-ci.yml index b1918961f3e8..60e52ffdf5ec 100644 --- a/.gitlab/ci/setup.gitlab-ci.yml +++ b/.gitlab/ci/setup.gitlab-ci.yml @@ -23,6 +23,18 @@ cache gems: - .default-retry needs: [] +dont-interrupt-me: + extends: .setup:rules:dont-interrupt-me + stage: prepare + image: alpine:edge + interruptible: false + allow_failure: true + variables: + GIT_STRATEGY: none + dependencies: [] + script: + - echo "This jobs makes sure this pipeline won't be interrupted! See https://docs.gitlab.com/ee/ci/yaml/#interruptible." + gitlab_git_test: extends: - .minimal-job diff --git a/doc/development/pipelines.md b/doc/development/pipelines.md index 5e2b5b3c230f..bfd184d7d5a2 100644 --- a/doc/development/pipelines.md +++ b/doc/development/pipelines.md @@ -142,6 +142,15 @@ and included in `rules` definitions via [YAML anchors](../ci/yaml/README.md#anch | `code-qa-patterns` | Combination of `code-patterns` and `qa-patterns`. | | `code-backstage-qa-patterns` | Combination of `code-patterns`, `backstage-patterns`, and `qa-patterns`. | +## Interruptible jobs pipelines + +By default, all jobs are [interruptible](../ci/yaml/README.md#interruptible), except the +`dont-interrupt-me` job which runs automatically on `master`, and is `manual` +otherwise. + +If you want a running pipeline to finish even if you push new commits to a merge +request, be sure to start the `dont-interrupt-me` job before pushing. + ## Directed acyclic graph We're using the [`needs:`](../ci/yaml/README.md#needs) keyword to -- GitLab