https://github.com/mvxt/circleci-demo-context-cli
Repository showcasing usage of CircleCI's new context CLI functionality
https://github.com/mvxt/circleci-demo-context-cli
cicd circleci circleci-cli circleci-demos circleci2 context continuous-delivery continuous-deployment continuous-integration demo keys secrets tokens
Last synced: about 2 months ago
JSON representation
Repository showcasing usage of CircleCI's new context CLI functionality
- Host: GitHub
- URL: https://github.com/mvxt/circleci-demo-context-cli
- Owner: mvxt
- License: mit
- Created: 2020-03-06T18:27:31.000Z (about 5 years ago)
- Default Branch: master
- Last Pushed: 2020-05-13T20:47:51.000Z (almost 5 years ago)
- Last Synced: 2025-01-20T02:42:10.095Z (4 months ago)
- Topics: cicd, circleci, circleci-cli, circleci-demos, circleci2, context, continuous-delivery, continuous-deployment, continuous-integration, demo, keys, secrets, tokens
- Homepage: https://circleci.com/changelog#manage-contexts-with-the-cli
- Size: 26.4 KB
- Stars: 0
- Watchers: 2
- Forks: 4
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# CircleCI Contexts CLI Demo [](https://circleci.com/gh/mvxt/circleci-demo-context-cli)
Repository showcasing usage of CircleCI's new context CLI functionality.
## Prerequisites for this example project
- Need to have the following env variables set, either project-level or context-level:Variable | Description
---------------------|------------------------------------------------------------------------------
`VCS` | Either "github" or "bitbucket"
`CIRCLECI_CLI_TOKEN` | A personal API token for CircleCI. User must have org-level/admin permissions## What's happening in this example config?
1. We use the [CircleCI CLI Orb](https://circleci.com/orbs/registry/orb/circleci/circleci-cli) to install the client-side CLI and setup auth with the `CIRCLECI_CLI_TOKEN` variable.```yaml
orbs:
circleci-cli: circleci/[email protected]# ...
jobs:
context-cli-test:
# ...
steps:
- circleci-cli/install
- circleci-cli/setup
```2. Then we demonstrate the Context CLI functionality in multiple steps. Here are the commands showcased:
Command | Description
---------------------------------------------------------|-------------------------------------------------------------------
`circleci context list $VCS $PROJECT_USERNAME` | Lists all contexts for this organization (e.g. "project username")
`circleci context create $VCS $PROJECT_USERNAME $CONTEXT_NAME` | Creates a new context under this organization
`circleci context delete -f $VCS $PROJECT_USERNAME $CONTEXT_NAME` | Deletes a context under this org. Normally you can't delete contexts that contain keys, but `-f` will override. **Use with caution**, delete keys and contexts cannot be recovered.
`circleci context show $VCS $PROJECT_USERNAME $CONTEXT_NAME` | Shows all of the keys (w/ masked values) of context
`circleci context store-secret $VCS $PROJECT_USERNAME $CONTEXT_NAME $KEY_NAME` | Creates new KV pair in context
`circleci context remove-secret $VCS $PROJECT_USERNAME $CONTEXT_NAME $KEY_NAME` | Deletes key in context`$VCS` you should have set as a prerequisite, and `$CIRCLE_PROJECT_USERNAME` refers to the org name owning the current project.
Run `circleci context` or `circleci context -h` for more help and information on available commands.