Injecting secrets with doppler run

When using doppler run, only printenv shows secrets. Accessing environment variables with $VARIABLE doesn’t work.

Hi @kartikye :wave:

This is happening because the $VARIABLE is getting processed in the current shell, not in the process that doppler run creates.

You’ll need to use the --command form instead, e.g. performing a curl request using Basic Authentication:

doppler run --command='curl -u $USER:$TOKEN https://example.com'

Or if you’re wanting to use a single secret in a command, you can use a sub-shell:

echo "The current project is $(doppler secrets get DOPPLER_PROJECT --plain)"

This is covered in our CLI install documentation for future reference.

I’m on Windows and I can’t get these to work. We want to pass a secret to an npx command in our package.json.

Our command is like so:
doppler run --command=“npx swagger-typescript-api -p $SWAGGER_URL -t ./src/api/templates -o ./src/api -n index.ts --union-enums --axios --disableStrictSSL”

Where $SWAGGER_URL is the secret in Doppler.

And the sub-shell example works within PowerShell (VSCode):
curl $(doppler secrets get SWAGGER_URL --plain) > swagger.json

But it does not work adding to package.json and calling with yarn. How can I inject this URL into the npx command so yarn can use it?