[CI Variables] Add Merge Request Variable
Description
Use case
Setting up a build task that posts the coverage report for a merge request as a comment on the merge request (filtered by the files that the merge request modified).
Issue
The problem is that I have no way of associating the build with the merge request that triggered it.
- The CI variables do not contain a reference to the merge request
- The Build API does not contain a reference to the merge request
- The Pipeline API does not contain a reference to the merge request
Observations
The build page provides a link to the merge request in the job details, so the information is readily available.
Proposal
Expose a CI variable for the merge request as CI_MERGE_REQUEST_ID
when applicable.
Workaround
Iterate through all the merge requests using the API until the build's commit is found. I do not plan on resorting to this.