I am attempting to use the -e option on the circleci cli to provide env vars, but cannot get them to work: Sample config:
The following config.yml:
version: 2.1
jobs:
print-env:
docker:
- image: buildpack-deps:trusty
steps:
- run:
command: |
printenv
export MY_INT_ENV_VAR=a_value;
echo "MY_INT_ENV_VAR=$MY_INT_ENV_VAR";
echo "MY_VAR=$MYVAR";
echo "Env var A passed with -e option should be FOO, but is: $A **";
echo "Env var B passed with -e option should be BAR, but is: $B **";
workflows:
version: 2
test:
jobs:
- print-env:
name: "test-printenv"
executed locally with:
circleci local execute -e A=FOO -e B=BAR -c env.yml --job test-printenv
produces:
Docker image digest: sha256:c9253479d1502905c0ecae748b0549ae3e0db7bfbf6c09540dff51d4a0b8f827
====>> Spin up Environment
Build-agent version 1.0.23182-56371fc3 (2020-01-03T11:27:39+0000)
Docker Engine Version: 19.03.8
Kernel Version: Linux 4acd432a475c 4.19.76-linuxkit #1 SMP Thu Oct 17 19:31:58 UTC 2019 x86_64 Linux
Starting container buildpack-deps:trusty
using image buildpack-deps@sha256:bdafcfdbf9ecc32179bb31b781b4cda388a9dc9455c474a17a06550ab90acacc
Using build environment variables
BASH_ENV=/tmp/.bash_env-localbuild-1586981772
CI=true
CIRCLECI=true
CIRCLE_BRANCH=xxxxxx
CIRCLE_BUILD_NUM=
CIRCLE_JOB=test-printenv
CIRCLE_NODE_INDEX=0
CIRCLE_NODE_TOTAL=1
CIRCLE_REPOSITORY_URL=git@github.com:xxxx.git
CIRCLE_SHA1=9bf592a27fc2c967bb37c09xxxxxxxxxxxxxxxx
CIRCLE_SHELL_ENV=/tmp/.bash_env-localbuild-1586981772
CIRCLE_WORKING_DIRECTORY=~/project
Using environment variables from project settings and/or contexts
[A=**REDACTED**
The redacted variables listed above will be masked in run step output
====>> printenv
export MY_INT_ENV_VAR=a_value;
echo "MY_INT_ENV_VAR=$MY_INT_ENV_VAR";
echo "MY_VAR=$MYVAR";
echo "Env var A passed with -e option should be FOO, but is: $A **";
echo "Env var B passed with -e option should be BAR, but is: $B **";
#!/bin/bash -eo pipefail
printenv
export MY_INT_ENV_VAR=a_value;
echo "MY_INT_ENV_VAR=$MY_INT_ENV_VAR";
echo "MY_VAR=$MYVAR";
echo "Env var A passed with -e option should be FOO, but is: $A **";
echo "Env var B passed with -e option should be BAR, but is: $B **";
[A=**********
CIRCLE_BUILD_NUM=
HOSTNAME=9a537110937d
CIRCLE_NODE_TOTAL=1
CIRCLE_INTERNAL_SCRATCH=/tmp/circleci-034436250
CIRCLE_INTERNAL_TASK_DATA=/.circleci-task-data
CIRCLE_NODE_INDEX=0
CIRCLE_BRANCH=xxxxxxxxx
SSH_AUTH_SOCK=/tmp/circleci-999999999/ssh_auth_sock
CIRCLE_JOB=test-printenv
CIRCLE_WORKING_DIRECTORY=~/project
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
PWD=/root/project
CIRCLECI=true
SHLVL=1
HOME=/root
CIRCLE_SHA1=9bf592a27fc2c967bb37c09a99999999999999
CI=true
CIRCLE_REPOSITORY_URL=git@github.com:xxxxxxxxx.git
CIRCLE_INTERNAL_CONFIG=/.circleci-runner-config.json
BASH_ENV=/tmp/.bash_env-localbuild-1586981772
CIRCLE_SHELL_ENV=/tmp/.bash_env-localbuild-1586981772
_=/usr/bin/printenv
MY_INT_ENV_VAR=a_value
MY_VAR=
Env var A passed with -e option should be FOO, but is: **
Env var B passed with -e option should be BAR, but is: **
Any help would be appreciated.