Hello, my scenario is this, I want to define a job template, as the same thing runs multiple times under different conditions, depending on variables, and a different times during my pipeline. The job should also only run under certain conditions, so it needs “rules”, but the “when” should be determined by the actual job, not in the template. Based on this documentation, GitLab CI/CD pipeline configuration reference | GitLab, specifically the last line of the section that states
You can define
whenonce per rule, or once at the job-level, which applies to all rules. You can’t mix
whenat the job-level with
Unless I’m reading that wrong I should be able to do what I’m trying to achieve.
.a_job_template: script: - echo 'hello world' rules: - if: '$FOO == "bar"' - if: '$BAR == "foo"' job_runs_manually: extends: .a_job_template when: manual variables: FOO: bar job_runs_on_success: extends: .a_job_template variables: BAR: foo job_runs_always: extends: .a_job_template when: always
However, if I try this, or use the CI Lint tool, I get the following error
jobs:job_runs_manually config key may not be used with `rules`: when jobs:job_runs_always config key may not be used with `rules`: when
My questions are
- Is the documentation correct and can I achieve the desired outcome in this way?
- If the documentation is correct, is my implementation incorrect?
- If my implementation isn’t correct, what is the correct implementation?
- Is this a bug, do I need to raise a ticket with GitLab?