Reputation: 86697
Is it possible to print all defined secrets (or at least their keys) in a gitlab_ci.yml
script?
Pseudocode:
deploy:
stage: deploy
script: |
for KEY in $SECRETS
echo $KEY
done
Upvotes: 2
Views: 657
Reputation: 776
I believe getting the secrets alone is only possible if you already know which secrets exist in the pipeline. But in most images, such as the default ruby image, the env
command exists, which lists all env variables, both key and value.
All secrets should be contained within these variables, or at least be listed as a file from within there.
If you have control over how the secrets are named, you can also achieve your original result of only getting secrets, by filtering them. For instance, if you can name every secret with a postfix like _SECRET
, you could call
env | grep _SECRET=
and if, as in your original example you only want to list the values, you can call:
env | grep _SECRET= | cut -d = -f2-
Upvotes: 1