Unable to use case-insensitive regex flag in only/except for CI
Hi,
We maintain 2 key branches of our software, master
and release
. Production is always running the release
branch.
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 Urg-<issue-number>
or some other casing combination.
As part of CI any push to a remote branch will attempt to merge either master
or 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 master
.
The following regex :
/^urg-.*/i
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 not-urgent-job
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 not-urgent-job
.
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?