How do I use Doppler to inject environment variables into a Makefile?

Is there a way to use Doppler to inject variable to Makefile?

In example in the following only the second line prints out the correct information (when set with export).

Makefile

test:
	doppler run -- echo ${DB_SOURCE}
	echo ${DB_SOURCE2}

Hi @minahanse,

If using a CLI injected variable in the command within a Makefile, you’ll need to use the --command flag and escape the $ character:

test:
	doppler run --command 'echo "$$DB_SOURCE"'

If instead you want to use the CLI to inject variables into the process spawned by make, just use the standard standard environment variable syntax:

Makefile:

test:
	echo "${DB_SOURCE}"

Shell command:

doppler run -- make test

Worked perfectly, thank you so much.

1 Like

Great to hear @minahanse!