Expose job variables in API
Problem to solve
When I trigger a pipeline via the trigger API and pass some variables, I can open one of the pipeline's jobs in GitLab web interface, click on the Reveal Variables and see the passed variables:
But if I request the jobs via the https://gitlab.com/api/v4/projects/1/jobs endpoint, I don't see the variables in the response.
Further details
The use case.
In our development process, any person can deploy a separate environment for a given feature under development. The deployment pipeline is set up in GitLab, and on top of that we have a simple web app for non-tech users. When user chooses to deploy an environment for a feature-1, for example, the app triggers the pipeline via API and passes variables like variable[TICKET_ID]=feature-1.
And while the feature environment is beind deployed, the web app should display "Deploying" status for the user. "Feature environment is being deployed" in our case means that there is an in progres job on GitLab which was run with variables[TICKET_ID]=feature-1. And the idea was to just request a bunch of last jobs via API and check the variables they were run with. If there is a job with TICKET_ID=feature-1 then environment for that feature is still being deployed. But since variables aren't exposed in the jobs list API I don't see a way to map jobs to features.
Q&A
Why don't just maintain the mapping inside of the web app?
We do at the moment, but there are also other ways outside of the app to trigger the pipeline. And when such trigger happens the app cannot know about this and cannot understand that an environment for the feature is already being deployed.
Proposal
What does success look like, and how can we measure that?
Job variables are exposed in the jobs list API.
