Catalog / CircleCI Cheat Sheet
CircleCI Cheat Sheet
A comprehensive cheat sheet for CircleCI, covering configuration, commands, and best practices to streamline your CI/CD workflows.
Configuration Basics
`.circleci/config.yml` Structure
The Key Components:
|
Example:
|
Common Configuration Keys
|
Specifies the version of the CircleCI configuration language. Currently |
|
Defines individual tasks to be executed. Jobs contain steps. |
|
Orchestrates the execution of jobs, defining dependencies and sequencing. |
|
A list of commands or pre-defined actions executed within a job. |
|
Specifies the Docker image to use for the job’s execution environment. |
|
A special step that clones your repository into the workspace. |
Workflow Configuration
Workflows define how jobs are executed and orchestrated. Key features include:
|
Example:
|
Common Steps
Built-in Steps
|
Clones the repository into the workspace. Should be the first step in most jobs. |
|
Executes shell commands. The most versatile step. |
|
Saves files or directories to the cache for reuse in subsequent jobs. |
|
Restores files or directories from the cache. |
|
Uploads artifacts (e.g., test reports, binaries) to CircleCI for storage and retrieval. |
|
Saves data to a workspace that can be accessed by subsequent jobs in the workflow. |
|
Attaches the workspace to the current job. |
Using the `run` Step
The Common Attributes:
|
Example:
|
Caching
Caching is crucial for speeding up builds. Use Best Practices:
|
Example:
|
Orbs and Integrations
Using Orbs
Orbs are reusable packages of CircleCI configuration. They simplify configuration and enable integration with third-party services. Benefits:
|
Example: Using the Heroku Orb
|
Common Orbs
|
For deploying to Heroku. |
|
For interacting with AWS S3 buckets. |
|
For sending notifications to Slack channels. |
|
For running Docker Compose commands. |
|
For interacting with the Fastly CDN. |
|
For UI/browser testing |
Integrating with Services
CircleCI integrates with numerous services through orbs and custom configurations. Examples:
|
Advanced Features
Environment Variables
Environment variables are used to store sensitive information (e.g., API keys, passwords) and configure builds. Setting Environment Variables:
Accessing Environment Variables:
|
Example:
|
Workflow Parameters
|
Define parameters at the workflow level to customize job execution. These parameters can be passed to jobs. |
|
Specify the type of parameter (e.g., |
|
Set a default value for the parameter. |
|
Add descriptive text to the parameter, to help users understand the expected value |
Using SSH
Connect to remote servers using SSH. Useful for deploying applications or running remote commands. The Generating SSH Keys:
|
Example:
|