Hello,
Is it possible to pass environment variables set in the WebUI of CircleCI into the service image ?
Here is an example:
-
MY_ENV is defined in the config.yaml
-
MY_CI_ENV is defined in the WebUI
-
My_CI_ENV2 is the previous envar reset into the config.yaml
version: 2 jobs: test: docker: - image: alpine:latest - image: mongo:latest command: sh -c "env; echo MY_ENV=${MY_ENV};echo MY_CI_ENV=${MY_CI_ENV}" environment: - MY_ENV: bonjour environment: - MY_ENV: hello - MY_CI_ENV2: ${MY_CI_ENV} steps: - run: name: echo1 command: echo ${CIRCLE_BRANCH} - run: name: echo2 command: echo ${MY_ENV} - run: name: echo3 command: echo ${MY_CI_ENV} - run: name: echo4 command: echo ${MY_CI_ENV2} workflows: version: 2 just_do_it_now: jobs: - test
The output of the service image (mongo):
HOSTNAME=d42f6c3814ea
SHLVL=0
HOME=/root
NO_PROXY=127.0.0.1,localhost,circleci-internal-outer-build-agent
MY_ENV=bonjour
GPG_KEYS=9DA31620334BD75D9DCB49F368818C72E52529D4
TERM=xterm
MONGO_PACKAGE=mongodb-org
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
MONGO_MAJOR=4.0
JSYAML_VERSION=3.10.0
MONGO_REPO=repo.mongodb.org
GOSU_VERSION=1.10
PWD=/
MONGO_VERSION=4.0.3
MY_ENV=bonjour
MY_CI_ENV=
And here is the output of the “echo4”:
${MY_CI_ENV}