Add ability to pass variables to Create MR Pipeline API endpoint
Everyone can contribute. Help move this issue forward while earning points, leveling up and collecting rewards.
Problem to solve
Currently, one is able to pass environment variables when triggering a regular branch pipeline by running:
curl --request POST \
--form token=TOKEN \
--form ref=master \
--form "variables[UPLOAD_TO_S3]=true" \
https://gitlab.example.com/api/v4/projects/9/trigger/pipeline
However there is no way to pass environment variables (do the same thing as above) to the Create MR Pipeline API endpoint.
For example:
curl -v --request POST --header "PRIVATE-TOKEN: <TOKEN>" \
--form "variables[MYARG]=true"
"https://gitlab.example.com/api/v4/projects/1/merge_requests/37/pipelines"
does not work, as MYARG does not get passed to the pipeline's environment.
This is a limitation surfaced by a customer: https://gitlab.zendesk.com/agent/tickets/179508
Intended users
- Delaney (Development Team Lead)
- Sasha (Software Developer)
- Devon (DevOps Engineer)
- Sidney (Systems Administrator)
- Simone (Software Engineer in Test)
User experience goal
Users should be able to pass environment variables to MR branches (this is necessary in complex automation workflows).
Proposal
Introduce functionality so that we can allow variables to be picked up by a MR pipeline's environment.
Further details
https://gitlab.zendesk.com/agent/tickets/179508
Documentation
This change will need to be documented in https://docs.gitlab.com/ee/api/merge_requests.html#create-mr-pipeline
Availability & Testing
What does success look like, and how can we measure that?
Running:
curl -v --request POST --header "PRIVATE-TOKEN: <TOKEN>" \
--form "variables[MYARG]=true"
"https://gitlab.example.com/api/v4/projects/1/merge_requests/37/pipelines"
should result in a Pipeline who's environment variables also include MYARG=true