Post-merge pipeline status isn't showing the correct pipeline
Summary
Post-merge pipeline status isn't showing the pipeline linked to the merge. Instead it is showing the latest pipeline that run on the commit linked to the MR. Soon after the merge, the latest pipeline is the same as the first pipeline that run following the merge. After few minutes, this can change and the MR is updated with wrong pipeline information.
We should always see the pipeline resulting of what happens to the target branch as a consequence of the merge.
Steps to reproduce
1- Use this CI configuration:
workflow:
rules:
- if: $CI_PIPELINE_SOURCE == "merge_request_event"
- if: $CI_COMMIT_BRANCH
branchpipeline:
script:
- cat nonexistentfile.yml
except:
- schedules
- merge_requests
mrpipeline:
script:
- sleep 5
only:
- merge_requests
schedulepipeline:
script:
- sleep 5
only:
- schedules
2- Create a pipeline schedule
3- Create an MR that you merged and will show correct post-merge pipeline status
4- After few minutes (you can manually trigger the pipeline schedule if needed), the MR is updated with an unrelated pipeline
Example Project
Reproduced on GitLab.com
What is the current bug behavior?
The Post-merge pipeline status is showing the latest pipeline that run on the commit linked to the MR. This leads to confusion as we expect to see the result of what happens to the target branch as a consequence of the merge.
What is the expected correct behavior?
When a merge request is merged, you can see the post-merge pipeline status of the branch the merge request was merged into.
- should be able to simply click in the MR on the new pipeline that was spun up as a result of the merge approval.
- The results of that pipeline should also be put back into the MR.

