I am having a devil of a time trying to replace a simple except rule with a rule. I am trying to exclude a job from running on the test and production branches (and during scheduled runs), but the whole pipeline is not running when merging to test and I do not understand why. Here is the pertinent CI code:
The workflow rules were added to prevent duplicate merge/branch pipelines. As I noted it seems the restriction in the job rules is killing the entire pipeline, and I do not understand why this is.
Here, you are restricting your pipelines to only run when the source is a merge request event or the branch is the default branch.
You say that the pipeline won’t run when “merging to test”. Does that mean that after you have merged an MR to the test branch, you are not getting a pipeline running on test? If so, that’s because if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH would exclude that case, if test is not your default branch.
Thanks so much for the guidance. I suppose to fix I might want to use - if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH || $CI_COMMIT_BRANCH == "test" || $CI_COMMIT_BRANCH == "production" or something similar?
Well, you don’t have to use the templates, you can make your own rules, and as you’ve probably noticed, they are just bits of Bash code. I would give it a go and see how you get on. I keep a throwaway repo that I use for testing this sort of thing, which makes it a little easier to rebase your “real” commit history.