3

I`m new to Gitlab-CI and would like to trigger a script in Gitlab CI if changes are made to files in a defined folder and there has either been a push to the master branch OR some other branch has been merged into master. After reading the docs I think this could work:

    trigger_something:
      rules:
        - changes:
          - path2importantstuff/*
        - if: '$CI_PIPELINE_SOURCE == "merge_request_event" && $CI_MERGE_REQUEST_TARGET_BRANCH_NAME == "master"'
        - if: '$CI_PIPELINE_SOURCE == "push" && $CI_COMMIT_BRANCH == "master"'
      script:
        - curl --data-urlencode "argString=-ExecutionMode 'Real Run'" 127.0.0.1:2220/api/11/job/47c7c848/run

Is it possible to combine if conditions like this? Are they combined with a logical OR? Can something be improved?

Thank you - all the best, Sacha

Sacha Vorbeck
  • 327
  • 1
  • 2
  • 14

1 Answers1

0

I was a bit late.

But here's your answer.

You were right, they combined with a logical OR, not AND.

Any of those IF hit will trigger the job.

Update: I'm working on gitlab ci configuration and this is the right behavior, I've tested

LuongPham
  • 81
  • 10
  • Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Sep 26 '21 at 06:05