1

Is it possible to configure a job in a gitlab pipeline to only run once, when a merge request is created?

Using the rule "

'$CI_PIPELINE_SOURCE == "merge_request_event"'

" does not work, as it will also be triggered when there are new commits to the branch with the open merge request.

laoal11
  • 19
  • 1
  • 1
    Is this [similar to that question and its answer](https://stackoverflow.com/a/71355435/6309)? – VonC Nov 02 '22 at 07:32
  • Sadly it's not, this pipelines will run on any commit when a merge request is open. I am looking for a way to only run a pipeline job on the creation of a merge request – laoal11 Nov 07 '22 at 15:23

1 Answers1

0

You can use workflow to manage your pipeline. For example:

workflow:
  rules:
    - if: '$CI_PIPELINE_SOURCE == "merge_request_event"'
    - if: "$CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH"
    - if: '$CI_PIPELINE_SOURCE == "schedule"'

This workflow will only be triggered when merge, default branch commit, schedule

Adex0401
  • 1
  • 1