Skip to content

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

Open
@timvisher

Description

@timvisher

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions