GitLab CI: MERGE_REQUEST_EVENT not triggered by update?
I'm testing GitLab CI pipelines.
I have created a merge request named "TEST" that have its gitlab-ci.yml
with a rule like below:
if '$CI_PIPELINE_SOURCE == "merge_request_event" && $CI_MERGE_REQUEST_TITLE == "TEST"'
It worked fine as I expected. Create event triggered the merge_request_event
.
However, if I create a merge request have another title and then I update it to "TEST", It doesn't seems to trigger the merge_request_event
.
According to this document, merge_request_event
is supposed to be triggered by updated too.
For pipelines created when a merge request is created or updated. Required to enable merge request pipelines, merged results pipelines, and merge trains.
Do I take it wrong or missed important information or documents?
Pushing to a branch will trigger a pipeline, and if that branch has an associated Merge Request, then the variable CI_PIPELINE_SOURCE
will be equal to merge_request_event
.
On the other hand, afaik just editing the title of a Merge Request on the GitLab UI will not trigger a pipeline, so your logic will never be evaluated unless you also push to the branch.
The documentation is correct, but perhaps the meaning is not 100% clear.
For pipelines created when a merge request is created or updated.
Stated more precisely:
When an MR action creates a pipeline, $CI_PIPELINE_SOURCE
will be equal to merge_request_event
However, it does not mean to imply that any update will create a pipeline. Updating the MR title does not create a pipeline, so this is not applicable to that scenario.
However, after you have changed the title, if some other event creates a new pipeline (specifically: push events to the MR source branch or manually running a new pipeline on the MR), the rule will evaluate to true and the job will be included in the created pipeline.
Per the docs:
Merge request pipelines:
- Run when you:
- Create a new merge request.
- Push a new commit to the source branch for a merge request.
- Select Run pipeline from the Pipelines tab in a merge request.