CLI tool for managing CircleCI contexts and environment variables.
uv tool install circleci-env-clipip install circleci-env-cliuvx circleci-env-cli [OPTIONS]docker pull phsmith/circleci-env-cli:[VERSION]
# Run example
docker run --rm -it \
-v $HOME/project/.env:/env \
-e CIRCLE_TOKEN=${CIRCLE_TOKEN} \
phsmith/circleci-env-cli:latest [OPTIONS]A CircleCI personal API token must be created before using this tool.
All options can be specified as environment variables in the format:
CIRCLE_<OPTION>.Example:
CIRCLE_TOKEN=********
Usage: circleci-env-cli [OPTIONS]
CLI tool for manage CircleCI contexts and environment vars
Options:
--version Show the version and exit.
-u, --api-url <circleci_api_url>
[default: https://circleci.com/api]
-t, --token <circleci_token> [default: (CIRCLE_TOKEN)]
-c, --context <context_name> It will ask for create if does not exists
-p, --project <project_slug> Example: github/org-name/project-name
[required]
-e, --env <environment_var>
-ef, --env-file <environment_vars_file>
-l, --list-envs
-d, --delete Delete mode. Behavior depends on other
options:
-c only: delete the entire context
-c + -e/-ef: delete specific context vars
-e/-ef only: delete specific project vars
-ot, --owner-type <owner_type> [default: organization]
--debug
--help Show this message and exit.
$ circleci-env-cli -p github/myorg/myproject -l
> Project variables (2):
KEY1
KEY2$ circleci-env-cli -p github/myorg/myproject -e KEY1=VAL1 -e KEY2=VAL2 -ef project.envs.txt
> Successfully added/updated variable: KEY1
> Successfully added/updated variable: KEY2
> Successfully added/updated variable: KEY3
> Successfully added/updated variable: KEY4The env file (-ef) must contain one KEY=VALUE pair per line:
KEY3=VAL3
KEY4=VAL4$ circleci-env-cli -p github/myorg/myproject -e KEY1 -e KEY2 -d
> Successfully deleted variable: KEY1
> Successfully deleted variable: KEY2$ circleci-env-cli -p github/myorg/myproject -c mycontext -l
> Context variables (2):
KEY1
KEY2$ circleci-env-cli -p github/myorg/myproject -c mycontext -e KEY1=VAL1 -e KEY2=VAL2
The context named "mycontext" was not found. Do you want to create it? [y/n]: y
> Successfully created context: mycontext
> Successfully added/updated context variable: KEY1
> Successfully added/updated context variable: KEY2$ circleci-env-cli -p github/myorg/myproject -c mycontext -e KEY1 -e KEY2 -d
> Successfully deleted context variable: KEY1
> Successfully deleted context variable: KEY2$ circleci-env-cli -p github/myorg/myproject -c mycontext -d
Are you sure want to delete the context "mycontext"? [y/n]: y
> Successfully deleted context: mycontext