When: never triggered

Hello,
Version 13.9.1-ee
if i trigger this URL GITLAB_SERVER + “api/v4/projects/4/trigger/pipeline”
have these rules in a job “build_live”

 rules:
    - if: '$CI_COMMIT_BRANCH == "master"'
      changes:
        - "folder1/**/*"
        - "folder2/**/*"
    - if: '$CI_PIPELINE_SOURCE == "trigger"'
      when: never

the job executes. But it should not because of the when:never in ‘$CI_PIPELINE_SOURCE==“trigger”’ Why is this happening? Thank you

Hi @srink

can you please format your config as code? There’s a button in the editor that looks like: </> and this will help us see whether the problem is with the whitespace in your file.

I have reformatted the code part

Thank! Is that all the rules for the job?

I’d suggest you try this, although it seems a bit unnecessary:

 rules:
    - if: $CI_COMMIT_BRANCH == "master" && $CI_PIPELINE_SOURCE != "trigger"
      changes:
        - "folder1/**/*"
        - "folder2/**/*"
      when: on_success
    - if: '$CI_PIPELINE_SOURCE == "trigger"'
      when: never

Yes, that is all the rules for the job. It would be nice to get an understanding why the job can be triggered though.

Did you have a go at the changes I suggested BTW?

Yes, i tried the changes and they work. Thank you for that.

So, I think it happened because when the trigger was sent, there was a change in one of the listed folders folder1, folder2, on the master branch. This would have matched the first clause in your rule, which runs on_success, and so the pipeline ran.

Without the && $CI_PIPELINE_SOURCE != "trigger" in that clause, the pipeline will run without the second clause being considered.

Hope that helps a bit!

@srink
rules are evaluated in the order you specify them (from top to bottom). First match wins.
As @snim2 mentioned, you most likely had changes in folder1 or folder2 so that rule matched and the 2nd wasn’t checked anymore.

Super, thank you all!