I would like to update ci/cd variables in gitlab pipeline, so that the pipeline is able to update values of existing variables.
How would I do that? Is there any built-in feature for that? Or do I have to build a script which use the REST-API of gitlab ci /cd variables?
I’m assuming you’re referring to custom project and/or group level variables one defines via the UI ?
There is a REST API endpoint for updating (PUT) project & group level variables but as Jean pointed out, not the Gitlab predefined variables (CI_PROJECT_*). I’m also assuming you want to change these so later pipeline instances can make use of the revised values? Otherwise, these are injected as env variables & you can alter them as one might do with any variables. To be fair, I’ve not experimented to see if any of the predefined vars are injected as read-only variables (bash’s declare -r name=val).
Can you be a little bit more explicit about what you need to do? Do you just need to update the variables within a pipeline, or do you really need to write the new variables back to the project for future pipelines to pick up?