Specify "when" at job level, with a job that has rules

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 when once per rule, or once at the job-level, which applies to all rules. You can’t mix when at the job-level with when in rules"

Unless I’m reading that wrong I should be able to do what I’m trying to achieve.


        - echo 'hello world'
        - if: '$FOO == "bar"'
        - if: '$BAR == "foo"'

    extends: .a_job_template
    when: manual
        FOO: bar

    extends: .a_job_template
        BAR: foo

    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?