Allow "attaching" a triggered pipeline to a merge request

Everyone can contribute. Help move this issue forward while earning points, leveling up and collecting rewards.

Problem to solve

I would like to trigger pipelines for commits related to, but not on a merge request. For example, we support "backport" branches via our own merge bot. I'd like to be able to attach a pipeline for the to-be-backported commit individually that we can trigger and have it show up in the MR. We can also create tentative merge commits and test those as well.

Intended users

Personas are described at https://about.gitlab.com/handbook/marketing/product-marketing/roles-personas/

Further details

The ability to trigger a pipeline and attach it to a (project, iid) pair so that it shows up in the given MR. I guess above-and-beyond would be the ability to attach it to a set of MRs (e.g., in the case of batch testing MRs together). It might need to be tied to a specific commit in the MR as well so that it can be properly expired on an MR update.

Proposal

Support for attach_to_project[]= and attach_to_mr[]= (and possibly attach_to_commit[]=) parameters to pipeline triggering endpoint (probably much easier in GraphQL, TBH, since lists are a thing there). The lists must be the same length and refer to existing MRs/commits. The pipeline only shows up as long as the commit (if provided) is part of the MR. The pipeline's status may be affected by the pipeline (this might need more parameters, but I'd be fine with it just being the default too).

I suppose infrastructure for multiple top-level pipelines in MRs would be needed. The expiration of the pipeline may also be tricky (not knowing the code).

Permissions and Security

If someone can trigger a pipeline for an MR today, that seems reasonable enough to me.

Documentation

Update the endpoint docs with the new parameter(s).

Availability & Testing

Would be useful in CE where folks cobble together their own bots to cover workflow gaps in the CE offering.

Links / references

Edited by 🤖 GitLab Bot 🤖