Hey everyone!
I’m currently trying to integrate Doppler into Gitlab CI and I came across a rather weird behavior.
To be honest, I’m not fully convinced that this is a bug in Doppler, but rather a quirk in the Alpine Linux shell. Since many Docker images are based on these small images I’m sure someone here came across the issue as well.
Context: Running a CI job in Gitlab using the ‘amaysim/serverless:2.18.0’ image as base. I can install Doppler, it also loads all variables correctly, but the variables are not substituted when I run ‘doppler run – somecommand --foo $BAR’.
This can be reproduced locally in the following way:
docker run -it -e DOPPLER_TOKEN=YOURTOKENHERE alpine
> apk add curl
> curl -Ls https://cli.doppler.com/install.sh | sh
> doppler run -- printenv # <- All perfect here (loads AWS_ACCESS_KEY_ID)
> echo $DOPPLER_TOKEN # <- Still as expected
> doppler run -- echo $AWS_ACCESS_KEY_ID # <- !!! Empty !!!!
> doppler run -- echo $DOPPLER_TOKEN # <- Shown as expected
My verdict is:
- Doppler CLI loads all variables correctly (correct value for AWS_ACCESS_KEY_ID)
- Variables that are available in the shell (e.g. DOPPLER_TOKEN) can be referenced both directly in the shell (echo $DOPPLER_TOKEN) as well as in the Doppler command (doppler run – echo $DOPPLER_TOKEN)
- Doppler variables are present to commands run by Doppler (doppler run – printenv)
- Doppler variables are not present in the Doppler shell (doppler run – echo $AWS_ACCESS_KEY_ID)
Here is what I tried so far (without success):
- /bin/sh -c “doppler run – echo $AWS_ACCESS_KEY_ID”
- doppler run --command “echo $AWS_ACCESS_KEY_ID”
- doppler run --command “/bin/sh -c ‘echo $AWS_ACCESS_KEY_ID’”
What “works” is creating a script:
#!/bin/sh
echo $AWS_ACCESS_KEY_ID
and then run it: doppler run – ./test.sh
But for some freaking reason, the variables cannot be referenced directly in the shell. Highly frustrating!
I’m a bit at a loss on how to solve this and would really appreciate some input.
Best wishes,
Johannes