Passing Travis environment variables to Docker

Hey @SolarUltima,

Remember in Travis, single quotes will prevent variable expansion.

In your .travis.yml, call your bash script via:

./deploy-cd.sh $PASSWORD

In your script deploy-cd.sh try adding the following near the top (near the shebang line, I’d recommend):

docker run -e password=$1 img_name

The $1 argument will be passed to the bash script and in turn, specifically in this case with Mongo $1 is the value of $PASSWORD which is stored in this case AS the env var in Travis, so it can be called correctly and accessed as a secret.

Happy building!
Montana Mendy
Travis CI Staff