Start Building for Free
CircleCI.comAcademyBlogCommunitySupport

Sample config.yml Files

1 month ago9 min read
Cloud
Server v4.x
Server v3.x
Server v2.x
Helpful Resources
On This Page

This document provides sample .circleci/config.yml files, as follows:

CirlceCI has created an extension for Visual Studio Code that reduces context switching for developers between the web app and VS Code through a set of helpful features.

The VS Code extension reduces the time to create, modify, and troubleshoot configuration files through real-time syntax validation, highlighting, and autocomplete suggestions. Authenticating the extension with your CircleCI account will also allow you to visualize and manage your CircleCI pipelines directly from your code editor, and be notified of workflow status changes.

The CircleCI VS Code extension is available to download on the VS Code marketplace.

Simple configuration examples

Concurrent workflow

The configuration example below shows a concurrent workflow in which the build and test jobs run at the same time. Refer to the Workflows document for complete details about orchestrating job runs with concurrent, sequential, and manual approval workflows.

This image shows the workflow view for the following configuration example: Concurrent Workflow Graph

Sequential workflow

The configuration example below shows a sequential job workflow where the build job runs and then the test job runs once build has completed. Refer to the Workflows document for complete details about orchestrating job runs with concurrent, sequential, and manual approval workflows.

This image shows the workflow view for the following configuration example, in which jobs run sequentially; one after the other: Sequential Workflow Graph

Approval job

The example below shows a sequential job workflow with an approval step. The build job runs, then the test job, then a hold job, with type: approval ensures the workflow waits for manual approval before the deploy job can run. Refer to the Workflows document for complete details about orchestrating job runs with concurrent, sequential, and manual approval workflows.

This image shows the workflow view for the following configuration example. This image has three parts to show the approval popup that appears when you click on a hold step in the app, and then the workflow view again once the hold job has been approved and the deploy job has run:

Approval Workflow Graph

Sample configuration with sequential workflow

Following is a sample .circleci/config.yml file using the following configuration features:

  • A sequential workflow
  • An orb (version: 2.1 config only, and server 3 users will need to ensure the orb has been imported) - the node orb handles caching automatically, but you can see saving and restoring caches in the version: 2.0/Server v2 example
  • A secondary services container
  • Workspaces
  • Storing artifacts

This example shows a sequential workflow with the test job configured to run only on the main branch. Refer to the Workflows document for complete details about orchestrating job runs with concurrent, sequential, and manual approval workflows.

Sample configuration with fan-in/fan-out workflow

Below are two sample configurations for a Fan-in/Fan-out workflow.

For the Server/2.0 config example, refer to the complete demo repo on GitHub for details.

For the Cloud/2.1 example, see the following workflow graph:

Fan-in-out

Note: a job can only run when its dependencies are satisfied therefore it requires the dependencies of all upstream jobs. This means only the immediate upstream dependencies need to be specified in the requires: blocks.

Sample configuration with multiple executor types

It is possible to use multiple executor types in the same workflow.

In Example-1 each push will build and test the project on Linux, Windows and macOS.

In Example-2 each push of an iOS project will be built on macOS, and additional iOS tools ( SwiftLint and Danger) will be run in Docker.

See also


Help make this document better

This guide, as well as the rest of our docs, are open source and available on GitHub. We welcome your contributions.

Need support?

Our support engineers are available to help with service issues, billing, or account related questions, and can help troubleshoot build configurations. Contact our support engineers by opening a ticket.

You can also visit our support site to find support articles, community forums, and training resources.