I would like to run one or multiple jobs within a scheduled context and therefore used the specific rule to declare it like this. Problem is that the pipeline will neither be triggered by my schedule configuration nor when i manually trigger it via the scheduling pipeline UI. I just don't see any triggered scheduled pipeline at all.
Gitlab Version: 12.9.2
gitlab-ci.yml (partially):
workflow:
rules:
- if: $CI_COMMIT_TAG
- if: $CI_COMMIT_BRANCH
non-scheduled-job:
...
rules:
- if: '$CI_PIPELINE_SOURCE != "schedule"'
scheduled-job:
...
rules:
- if: '$CI_PIPELINE_SOURCE == "schedule"'
when: always
- if: '$CI_PIPELINE_SOURCE != "schedule"'
when: never
I know that the second rule for the scheduling-job is not needed but even without this the pipeline is not properly running.
Unfortunately, as for Workflows logic, Gitlab is very twiggy. If you use Workflow section and Rules conditions for your jobs, you have to obviously declare 'Scheduled' type of pipeline in the Workflow section to enable it in your configuration:
workflow:
rules:
- if: '$CI_PIPELINE_SOURCE == "schedule"'
...
Or you may enable all types of pipelines in your configuration just adding at the end of workflow:rules
workflow:
rules:
...
- when: always
In other way, use may use except/only notation for scheduled jobs and it will work, but only if your workflow conditions met:
only:
- schedules
This approach may appear merging conflicts if you use include option. Because merging lets you extend and override dictionary mappings, but you cannot add or modify items to an included array. Thus you have to obviously declare all previously added workflow:rules array items in the last included YAML or use anchors.
See issue for details.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With