Closed luke-riu closed 3 years ago
the current version doesn't support gain a secret key from envs
, this feature is under development, it will be included in next release.
you could use flow.ci api to get actual secret value as workaround, ex:
your_secret = $(curl -X GET "${FLOWCI_SERVER_URL}/api/secret/test-token-2" -H "AGENT-TOKEN: ${FLOWCI_AGENT_TOKEN}" -s | python3 -c "import sys, json; print(json.load(sys.stdin)['data']['token']['data'])")
echo $your_secret
if python
not available in your agent environment
your_secret = $(curl -X GET "${FLOWCI_SERVER_URL}/api/secret/test-token-2" -H "AGENT-TOKEN: ${FLOWCI_AGENT_TOKEN}" -s | grep -Eo '"data"[^,]*}' | sed 's/"data":"//; s/"}}}//')
echo $your_secret
Ah that's excellent news. Thanks 😊
Hi. I was wondering if this was resolved in the latest release. Thanks.
yes, here is an example, you could ref the secret from YAML block secrets
, and use it as an environment variable
- name: test
docker:
image: flowci/debian-git
secrets:
- 'test_token'
bash: |
echo ${test_token}
Perfect. Thank you :)
In my config I have a token called
service_key
I have a step something like this:
but the input parameter in the script just receives "service_key" as a value, rather than the actual value stored in the secrets. How do I get the actual secret into the script? Thanks