Intro to config.yml file

As previously mentioned, while working through the workshop modules, you will progressively build a CI/CD pipeline in the form of a CircleCI config.yml file. CircleCI is a proponent of configuration as code. As a result, the entire delivery process from build to deploy is orchestrated through a single file called config.yml. The config.yml file is located in a folder called .circleci/ at the top of your project. CircleCI uses the YAML syntax for defining pipeline configurations.

Programming the config.yml

You will progressively build a fully functional config.yml file that will ultimately demonstrate how to build, test, security scan. and deploy code changes with every commit. We will provide all of the code snippet elements, with explanations, you will need to build the config.yml file through the modules. The code snippets will look similar to this example:

version: 2.1
      - image: circleci/node:14.0
      - checkout
      - run: npm install

This example is the beginning of a config.yml pipeline and you will append more code snippet examples to the config.yml as you progress through the modules. After completing all the modules you will have a complete CI/CD pipeline that will execute on CircleCI.

Core elements of the config.yml

Let’s take moment to learn about the most critical elements within the config.yml file so that you have a better understanding of how to define effective CI/CD pipelines.

The config.yml is composed of four core elements:

  • Executors: Executors define the environment in which the steps of a job will be run, allowing you to reuse a single executor definition across multiple jobs.
  • Jobs: Jobs are a grouping of commands the produce a desired result when executed.
  • Commands: Commands are the directives to be executed such as an npm install or unit test execution.
  • Workflows: Workflows orchestrates how and when jobs are executed when pipelines are triggered.

As you progress through this workshop you should gain familiarity and a better understanding of these elements and how they function.

YAML requires indentation to properly structure elements and also requires those indentations to be spaces and not Tabs. Improper indentation will created formatting errors rendering your YAML invalid until fixed.

In the next you will learn how create the begginings of a config.yml file and implement automated testing job.