Hey folks,
I’m trying to create a pipeline where the last step destroys an environment. The entire pipeline looks as follows:
variables:
TF_IMAGE: python:3.8-slim-buster
stages:
- "Analysis/Test"
- "Deploy Branch"
- Cleanup
.terraform_defaults:
image:
name: $TF_IMAGE
resource_group: $CI_COMMIT_REF_SLUG
variables:
WORKSPACE: "tf-${CI_COMMIT_REF_SLUG}"
analyze:
stage: "Analysis/Test"
image:
name: python:3.8-slim-buster
script:
- echo "Running tests"
deploy_branch:
extends: .terraform_defaults
stage: "Deploy Branch"
environment:
name: review/tf-$CI_COMMIT_REF_SLUG
on_stop: destroy_branch
auto_stop_in: 1 week
rules:
- if: '$CI_COMMIT_BRANCH == "stable"'
when: never
- if: '$CI_COMMIT_BRANCH =~ /^noenv\/.*/'
when: never
- when: always
script:
- echo "Deploying branch"
destroy_branch:
extends: .terraform_defaults
stage: Cleanup
environment:
name: review/tf-$CI_COMMIT_REF_SLUG
action: stop
rules:
- if: '$CI_COMMIT_BRANCH == "stable"'
when: never
- if: '$CI_COMMIT_BRANCH =~ /^noenv\/.*/'
when: never
- when: manual
variables:
GIT_STRATEGY: none
script:
- echo "Deleting branch"
When I run this pipeline, and all pre-cleanup steps succeed, the result is the following:
Instead I’d expect it to look like this:
I can achieve this by removing the rules
section in the destroy_branch
step, and instead adding:
when: manual
except:
- stable
- /^noenv\/.*/
I’m not entirely sure why these two configurations yield different results, but optimally I would want to avoid the use of except
, since it is deprecated as far as I can tell from the documentation.
My assumption at the moment is that I’ve misunderstood something about the rules what I wrote, but this could also be a bug, possible related to:
- Pipeline doesn't succeed when manual jobs using new DAG dependency "needs:" are waiting for other "when: manual" jobs to succeed (#31264) · Issues · GitLab.org / GitLab · GitLab
- when: manual is blocking pipeline even though it shouldn't (#31415) · Issues · GitLab.org / GitLab · GitLab
Can someone shed some light on this issue? I want to avoid opening a bug until I’m sure that it’s not a RTFM situation
Environment
I’m using Gitlab.com (i.e. not self-hosted) but the runners are self-hosted (v14.2.0
)