Hello,
I would like to use the merge trains and also the merged result pipeline. Both are very good features. I would also like to use a branch pipeline with the source branch of the merge request, for example when the merge request is still in draft status.
Unfortunately, I can’t find any hint in the documentation on how to solve this problem. GitLab always starts a merged result pipeline:
$CI_PIPELINE_SOURCE = merge_request_event
$CI_MERGE_REQUEST_EVENT_TYPE = merged_result
The variable CI_MERGE_REQUEST_EVENT_TYPE
never has the value detached
when I push to the source branch of the merge request.
I handle the pipelines as follows:
workflow:
rules:
# When a push is made on the default branch, we always want to start the pipeline
- if: '$CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH'
when: always
# When a push is made on the main branch, we always want to start the pipeline
- if: '$CI_COMMIT_BRANCH == "main"'
when: always
# Creates a pipeline when a merge request is created/updated
- if: '$CI_PIPELINE_SOURCE == "merge_request_event"'
when: always
# No pipeline is created if there are open merge requests on this branch
- if: '$CI_COMMIT_BRANCH && $CI_OPEN_MERGE_REQUESTS'
when: never
# When a push is made on a branch, we always want to start the pipeline
- if: '$CI_COMMIT_BRANCH'
when: always
How do I set the workflow of a pipeline so that there is a pipeline
- for a branch, if there is no merge request for the branch
- for the branch of a merge request, if the merge request is in draft status
- for a merged result, if the merge request is in ready status?