Yash Hirulkar
Yash Hirulkar

Reputation: 25

I want to trigger gitlab ci pipeline only when 1 of the below 2 conditions are met

I want to trigger gitlab ci pipeline only when 1 of the below 2 conditions are met.

Upvotes: 1

Views: 458

Answers (1)

VonC
VonC

Reputation: 1324317

You should be able to use a set of workflow rules:

That would be in your case:

rules:
    - if: '$CI_COMMIT_MESSAGE =~ /BUILD_CONTAINER_IMAGE/'
      when: always
    # pipeline should run on merge request to master branch
    - if: $CI_PIPELINE_SOURCE == 'merge_request_event' && $CI_MERGE_REQUEST_TARGET_BRANCH_NAME == 'master'
      when: always
    # pipeline should run on merge request to main branch
    - if: $CI_PIPELINE_SOURCE == 'merge_request_event' && $CI_MERGE_REQUEST_TARGET_BRANCH_NAME == 'main'
      when: always
    - when: never

Upvotes: 1

Related Questions