How to get all Travis CI environment variables, excluding the default system ones?
I want to pass into
docker run all the environment variables I’ve configured in the Travis web UI.
I’m able to run
env > .env to save them to a file and then pass that into docker via
Unfortunately, this also overrides system ones such as
PATH that interfere with the container.
I’m able to filter out
env | grep -vE "^(PATH=)" > .env but I’m wondering whether there’s a way to get just the Travis ones?
Here’s my .travis.yml:
language: bash sudo: required services: - docker before_install: - env | grep -vE "^(PATH=)" > .env install: - docker build -t mycompany/myapp . script: - docker run -i --env-file .env mycompany/myapp nosetests after_success: - echo "SUCCESS!"
One Solution collect form web for “How to get all Travis CI environment variables, excluding the default system ones?”
I don’t recommend passing all your environment vars, but if you whitelist them by prefixing them with something like, say,
TRAVIS_ you could do something like:
export TRAVIS_WUT=foo export TRAVIS_FOO=asdf docker run $(printenv | grep -E '^TRAVIS_' | sed 's/TRAVIS_/-e /g') # would run -> docker run -e FOO=asdf -e WUT=foo something