How does using workflow:rules at the top level interact with rules defined (or even not defined) in a job? I haven’t been able to find this in the documentation.
For more reference, I want to be able to combine the two so that I can run a single job on schedule.
First I want to (by default) disable all jobs from running on schedule
workflow:
rules:
- if: $CI_PIPELINE_SOURCE == "schedule"
when: never
But I want this single job to run by essentially overriding the workflow:rules -
scheduled_job:
stage: test
script:
- echo "I ran..."
rules:
- if: $CI_PIPELINE_SOURCE == "schedule"
when: always
Clearly, this wont work because the pipeline will not be created in the first place. How can I achieve this functionality without changing ALL my jobs but by only changing workflow:rules and scheduled_job:rules?
You have to specify rules for reach job. Currently the workflow:rules determine if the pipeline is created as a whole, it is not possible to overwrite it with rules. workflow:rules does not function as default rules for all jobs. There is no interaction between those two.
runs weekly on scheduled jobs on the default branch (e.g. master or main); never otherwise on the default branch (so it doesn’t run if $RUN_MONTHLY is set, or whatever); but does run on feature branches (for testing).