Unable to use case-insensitive regex flag in only/except for CI
We maintain 2 key branches of our software,
release. Production is always running the
On occasion we will have an urgent issue which needs to be addressed before we merge our
master branch in to release as part of our usual cadence.
In these situations our developers will branch from
release using a branch name like
urg-<issue-number>. Otherwise we'll branch from
master with something like
<issue-number> as the branch name.
Now, sometimes a dev will create a branch like
Urg-<issue-number> or some other casing combination.
As part of CI any push to a remote branch will attempt to merge either
release into said branch to ensure there are no conflicts.
So, urg/Urg/URG branches should be merged against
release during CI and all other branches against
The following regex :
Will match against all of the combinations of case etc. that we encounter for our urgent branches.
Thus, the following YAML should be good :
urgent-job: only: - /^urg-.*/i not-urgent-job: except: - /^urg-.*/i
Should suffice for only running
urgent-job on urgent branches, otherwise run
However; in practice, both jobs run on all branches.
Experimenting we found the regex flag /i was causing the regex to effectively not be used at all, so the YAML was altered :
urgent-job: only: - /^urg-.*/ not-urgent-job: except: - /^urg-.*/
This results in the
urgent-job running only on
urg-* branches, which is great. However;
URG-* and other variants were running
The solution is this :
urgent-job: only: - /^[Uu][Rr][Gg]-.*/ not-urgent-job: except: - /^[Uu][Rr][Gg]-.*/
But this is obviously kind of gross.
So, the question is; can you use modifier flags on the end of your regex in the only / except sections of the YAML, and if so, what is the precise syntax to use?