One of the original hosted CI/CD systems.
- Key Points
- UI App
- CircleCI CLI
- Master Config Template
- Configs in Public Repos
- Self-Hosted Runner on Kubernetes
- CLI Usage
- SSH Debugging
- Advanced gotchas
Good UI but expensive, and undercut by GitHub Actions.
Not good for multi-jobs per repo compared to GitHub Actions which has overtaken it.
Docker Layer Caching costs 200 credits per job - 20 minutes of build time charges to save 3-5 minutes of actual Docker building in-job. WTF.
Charged via legacy up-front purchase order capacity, not PAYG like more modern cloud-hosted tech like AWS, GitHub etc.
https://app.circleci.com/pipelines
Follow the installation doc or paste this to run an automated installation script which auto-detects and handles Mac or Linux:
git clone https://github.com/HariSekhon/DevOps-Bash-tools
bash-tools/install/install_circleci.sh
Then configure it:
circleci setup
Copy to .circleci/config.yml
in the root of a Git repo and edit:
HariSekhon/Templates - circleci-config.yml
Most of my public GitHub repos have a .circleci/config.yml
file, eg:
HariSekhon/DevOps-Bash-tools - .circleci/config.yml
https://circleci.com/docs/runner-overview/
HariSekhon/Kubernetes-configs - circleci
Must be VCS org admin to create a namespace and each org can only have a single namespace (contact support to change it)
circleci namespace create <namespace> <vcs> <org>
eg.
circleci namespace create harisekhon github HariSekhon
Create runner token and save, it is only displayed once:
- Note: command doesn't work without description argument
circleci runner resource-class create harisekhon/docker-runner "Docker Runner" --generate-token
circleci runner resource-class create harisekhon/k8s-runner "Kubernetes Runner" --generate-token
See the runner (can't see in UI)
circleci runner instance list harisekhon
Delete a resource class
circleci runner resource-class delete harisekhon/docker
if you output like this:
Error: resource class harisekhon/docker still has tokens in use
then:
circleci runner token list harisekhon
output:
+--------------------------------------+----------+----------------------+
| ID | NICKNAME | CREATED AT |
+--------------------------------------+----------+----------------------+
| f3970f18-cdbb-4acf-ab11-6988e7d556e7 | default | 2021-12-13T19:02:48Z |
+--------------------------------------+----------+----------------------+
circleci runner token delete f3970f18-cdbb-4acf-ab11-6988e7d556e7
circleci runner resource-class delete harisekhon/docker
Silently succeeds
Can debug failing jobs with SSH, see this doc.
- No way to list runners and namespaces in the CircleCI UI
- No way to list namespaces in the CLI
- Conditionals - looks like it's all or nothing for a workflow or a step, whereas I want a job to be conditional - I could wrap all job's steps in a when step, but can't exclude all steps otherwise get this validation error
[#/jobs/docker_build/steps] expected minimum item count: 1, found: 0
| | SCHEMA:
| | minItems: 1
| | INPUT:
| | null#
Ported from private Knowledge Base page 2019+