Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enhance circleci local execute -e FOO to automatically read from the environment like docker #473

Open
timvisher opened this issue Sep 30, 2020 · 1 comment · May be fixed by #487
Open

Comments

@timvisher
Copy link
Contributor

What problem does this feature solve?:

Anyone coming from docker should immediately recognize the -e|--env
option as apeing docker's option of the same name. Unfortunately the
circleci local execute option doesn't behave in quite the same way.
Instead of allowing you to say circleci local execute -e AWS_ACCESS_KEY_ID, for instance, it forces you to circleci local execute -e "AWS_ACCESS_KEY_ID=${AWS_ACCESS_KEY_ID}" etc.

My proposal here would be to just bring that feature from docker to
circleci. If a variable is fully specified (-e FOO=BAR) then there's
no need to read it from the environment but if it's only specified by name
(-e FOO) then circleci can just resolve it as a variable in the
environment and error if it isn't found.

This is primarily to facilitate ease of local iteration.

Provide an example:

# x.yml
version: 2.1
jobs:
  build:
    docker:
      - image: bash
    steps:
      - run: echo "$FOO"
FOO=BOO circleci local execute
FOO=BOO circleci local execute --job build
…
====>> echo "$FOO"
  #!/bin/sh -eo pipefail
echo "$FOO"

Success!
# FOO is set in the environment but is not passed to local execute in any
# way so the echo is empty.


FOO=BOO circleci local execute -c x.yml -e FOO
…
====>> echo "$FOO"
  #!/bin/sh -eo pipefail
echo "$FOO"
BOO
Success!
# FOO is specified in the environment and passed to local execute and so
# the value from the environment is used


FOO=BOO circleci local execute -c x.yml -e FOO=BAR
…
====>> echo "$FOO"
  #!/bin/sh -eo pipefail
echo "$FOO"
BAR
Success!
# FOO is fully specified so despite being set in the environment the value
# passed explicitly is used
@timvisher timvisher linked a pull request Oct 8, 2020 that will close this issue
@timvisher
Copy link
Contributor Author

Ping. :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant