We would like to have two schedule pipelines that run at different pace and contain a different set of jobs each.
Say you have two jobs jobA
and jobB
that I’d like to run at two different paces, I could easily write a setup that looks like this:
variables:
PATTERN: jobA
jobA:
rules:
- if: $CI_JOB_NAME =~ $PATTERN
script:
- echo "this job should run if \$PATTERN = jobA"
jobB:
rules:
- if: $CI_JOB_NAME =~ $PATTERN
script:
- echo "this job should not run if \$PATTERN = jobA"
At this point I could easily have a schedule pipeline that overrides the $PATTERN
variable and decide which of the two jobs I want to run. The above seems to work as expected.
As soon as we get more ambitious with the pattern, things start to fall apart. Assume we have short jobs, long jobs and debug jobs, I might want to separate them in two schedules in this way:
variables:
PATTERN: '/^.*(short|long)$/'
jobA:short:
rules:
- if: $CI_JOB_NAME =~ $PATTERN
script:
- echo "this job is expected to run"
jobB:long:
rules:
- if: $CI_JOB_NAME =~ $PATTERN
script:
- echo "this job is expected to run"
jobC:debug:
rules:
- if: $CI_JOB_NAME =~ $PATTERN
script:
- echo "this job is not expected to run given the pattern above"
Unfortunately I did not get the pipeline to include those jobs and I’ve tried the following patterns so far:
PATTERN: '/^.*(short|long)$/'
PATTERN: "/^.*(short|long)$/"
PATTERN: /^.*(short|long)$/
PATTERN: '/(short|long)/'
PATTERN: '/long/'
PATTERN: '/.*long/'
PATTERN: 'long'
None of the above worked and I’m not really sure how to go about it. I’m running gitlab version 14.10 Premium version (on premises) and although I’ve noticed a couple of issues related to regex expansion, I still did not understand what I’m doing wrong.
Any help is appreciated!