Skip to content

phsmith/circleci-env-cli

Repository files navigation

circleci-env-cli

Build Status PyPI version Docker Image Version (latest semver) Docker Pulls

CLI tool for managing CircleCI contexts and environment variables.

Installation

Install via UV (recommended)

uv tool install circleci-env-cli

Install via Pip

pip install circleci-env-cli

Run without installing

uvx circleci-env-cli [OPTIONS]

Install via Docker

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]

Usage

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.

Examples

List project environment variables

$ circleci-env-cli -p github/myorg/myproject -l
> Project variables (2):
KEY1
KEY2

Add project environment variables

$ 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: KEY4

The env file (-ef) must contain one KEY=VALUE pair per line:

KEY3=VAL3
KEY4=VAL4

Delete project environment variables

$ circleci-env-cli -p github/myorg/myproject -e KEY1 -e KEY2 -d
> Successfully deleted variable: KEY1
> Successfully deleted variable: KEY2

List context variables

$ circleci-env-cli -p github/myorg/myproject -c mycontext -l
> Context variables (2):
KEY1
KEY2

Create/update context and add variables

$ 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

Delete context variables

$ circleci-env-cli -p github/myorg/myproject -c mycontext -e KEY1 -e KEY2 -d
> Successfully deleted context variable: KEY1
> Successfully deleted context variable: KEY2

Delete context

$ 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

About

CLI tool for manage CircleCI contexts and environment vars

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors