Doctor Who
Doctor Who

Reputation: 1659

Gitlab Rules: Manual step always shown even when rule met

We have a complex Gitlab pipeline, we've split the stages into different files and they are run based on the branch and source.

I'm trying to set up a schedule job to run that will just run one section of the pipeline, to do this I'm trying to use rules to ignore all other stages I don't want to run by doing something like this e.g.

    - if: $CI_PIPELINE_SOURCE == "schedule"   
          when: never

The problem is the stages also have a manual rule so even though I say skip if a schedule the pipeline still asks for a manual interaction:

  rules:
    - if: $CI_COMMIT_BRANCH == "master"
      when: never
    - if: $CI_PIPELINE_SOURCE == "merge_request_event"
      when: never
    - when: manual
    - if: $CI_PIPELINE_SOURCE == "schedule"
      when: never  

Is there a way I can skip this stage when the source is a "schedule" but still have the manual step for the other scenarios?

Upvotes: 7

Views: 10705

Answers (1)

Simon Schrottner
Simon Schrottner

Reputation: 4754

it is important to understand that rules are evaluated in the order you put them into the rules block.

this means your when:manual has precedence over your "Schedule" rule.

If you swap them like below, your schedule rule will be evaluated first, and you should not see a pipeline step see https://docs.gitlab.com/ee/ci/yaml/#rules

Rules are evaluated when the pipeline is created, and evaluated in order until the first match. When a match is found, the job is either included or excluded from the pipeline, depending on the configuration.

  rules:
    - if: $CI_COMMIT_BRANCH == "master"
      when: never
    - if: $CI_PIPELINE_SOURCE == "merge_request_event"
      when: never
    - if: $CI_PIPELINE_SOURCE == "schedule"
      when: never  
    - when: manual

Upvotes: 7

Related Questions