Pulling Variables to Local
git-vars package
Pulling Variables to a Local File
Export all environment variables from a GitLab repository to your local environment.
Prerequisites
Create a private directory outside the repository. Exported variables are plaintext secrets and must never be committed.
cd /path/to/your/repository
umask 077
mkdir -p ../ci-vars
Using Command Option
git-vars pull -s project -f ../ci-vars/project.env
# -s --scope (Optional): Need to choose one from 'project', 'group' or 'instance'. Default: The one provided in the `.git-vars` configuration file.
# -f --file: Output file where the variables are going to be exported. Always use a protected path outside the repository.
Verify that ../ci-vars/project.env was created with permissions that only allow your account to read it. Do not print real secrets to a shared terminal or job log. A redacted file uses the following format:
TEST=<REDACTED>
AWS_ACCESS_KEY_ID=<REDACTED>
AWS_DEFAULT_REGION=eu-central-1
AWS_SECRET_ACCESS_KEY=<REDACTED>
Variables follow the format KEY=VALUE. Delete the export securely when you no longer need it.