We have a optional Terraform CI task which should run only on master
or when the Terraform directory changes. Otherwise it should be manual:
.Terraform/plan:
stage: terraform-plan
needs: []
script:
- terraform --version
- ...
rules:
# plan will be built if the Terraform folder is changed
- changes:
- Terraform/*
when: always
# when building master branch
- if: '$CI_COMMIT_BRANCH == "master"'
when: always
# otherwise build only manually
- when: manual
However this has two flaws:
- Sometimes this job is run even though not on master and without the directory change. It is hard to debug to see which rule triggered the run.
- When the job is not triggered, it completely blocks the pipeline, even though it is to be run manually (see the pipeline blocked):
Can sb. point me in what I am doing wrong?