Authored by Dan Thomson

Print Gitlab CI/CD Variables as Environment Variables

Downloading and running this script locally can be done with either of the following commands:

$ curl -o
$ chmod 755 ./
$ ./

or by piping the script directly into bash:

$ curl | bash -

or by piping into bash and providing an argument (our private token file at /tmp/private-token):

$ curl | bash -s -- -p /tmp/private-token

You can use this script to pull your CI/CD variables out of a Gitlab project's CI/CD script (eg. your .gitlab-ci.yml) and print them as they would be printed to set the value in your bash shell (this probably only works with bash and zsh). If you eval the output from this script, you can automatically have those values exported into your environment. Eg:

$~ cd myproject
$~/myproject eval $(

This script is very simple but when coupled with the project variable script, you can export all relevant values from a project into your environment in order to easily debug your deployment without having to run the pipeline for every minor change.

Edited 9.58 KB
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment