I want to restrict the automatic creation of a pipeline as much as possible, as our pipelines take quite long and we have very limited resources.
A pipeline should therefore only be created if done manually or a push occurs on a specific branch. The thing I’m having troubles with is the “if done manually”-part.
Merge request events all seem to trigger the pipeline automatically. I’d like to stop that, which is easily done by checking if $CI_PIPELINE_SOURCE == "merge_request_event". However, manually pressing the “Run Pipeline”-Button on the Merge Request page also counts as a merge_request_event.
I’ve found no way to differentiate these two cases.
The more common case a pipeline is triggered on accident that way is when we’re creating a merge request. So I’d like to either disable that those events will be sent (or trigger a pipeline) or want some way to differentiate between manually starting the pipeline on the MR page and all other MR events.
Thanks for your help!
I already took an extensive look at those sources and also ran the pipeline once with a MR created event and once with the button and in both scenarios outputted all the available environment variables. Unfortunately, I couldn’t find any differences between those that would help me differentiate the use cases.
The $CI_PIPELINE_SOURCE is only web for the “Run Pipeline”-Button in the CI/CD > Pipelines section.
As written here in the comment: Merge requests API | GitLab the “Run Pipeline”-Button in the Merge Requests uses the Merge Request API and therefore the source is also categorized as merge_request_event.
No problems. I mean it is also the “Run pipeline” Button. But for some reason the “Run Pipeline” Button in the Merge Request page behaves differently to the “Run Pipeline” Button on the “Pipeline” Page. If they’d use the same API call I wouldn’t have this problem