Application Deployment and Security · Topic 3 of 8

CI/CD Pipelines and DevOps Principles

Learn the stages of a CI/CD pipeline for applications, the difference between delivery and deployment, a sample pipeline file and the principles of DevOps.

  • 4 min
  • Includes a diagram
In a nutshell
  • CI merges code often and runs an automatic build and test on each merge.
  • Continuous delivery keeps every passing change ready to release, with a manual approval.
  • Continuous deployment releases every passing change automatically.

What it is

A CI/CD pipeline is an automated path that takes a code change from a commit to a running application.

CI stands for continuous integration, and CD stands for continuous delivery or continuous deployment. DevOps is the wider way of working that makes such pipelines natural, by joining development and operations.

The aim is to release small changes often, with fewer errors and less manual work.

Commitdeveloper pushes codetriggersBuildcompile and packagerunsTestautomated checkspassesDeployrelease to an environment

How it works

A pipeline is a series of stages, and a failure in one stage stops the change from moving on.

Continuous integration

Developers merge their work into a shared branch often, for example several times a day. Each merge triggers an automatic build and a set of automated tests.

The benefit is quick feedback. A broken change is found within minutes, while the developer still remembers it.

Continuous delivery and continuous deployment

A commit is built, tested and stored as an artifact; in continuous delivery a person approves the release to production, while in continuous deployment it goes to production automatically.

TermMeaning
Continuous deliveryEvery change that passes the pipeline is ready to release, and a person approves the final step
Continuous deploymentEvery change that passes the pipeline is released automatically, with no manual approval

Pipeline components

ComponentRole
Source controlHolds the code, usually in Git. A commit or merge starts the pipeline
BuildCompiles code and creates a package or a container image
Automated testsUnit tests, integration tests and checks for style or security
Artifact repositoryStores the built packages and images, with version numbers
DeployReleases the artifact to a test, staging or production environment
Monitoring and feedbackWatches the running application and feeds problems back to the team

A pipeline is usually described in a file kept in the repository, a practice called pipeline as code. This is a simple example in the style of GitLab CI.

stages:
  - build
  - test
  - deploy

build_job:
  stage: build
  script:
    - docker build -t myapp:1.0 .

test_job:
  stage: test
  script:
    - python -m unittest discover

deploy_job:
  stage: deploy
  script:
    - ./deploy.sh staging

The stages list sets the order. Each job names its stage and lists the commands in script. Jenkins, GitHub Actions and GitLab CI follow the same idea with different file formats.

Environments and release strategies

Changes often flow through several environments: development, test, staging and production. Each one is closer to the real thing.

Teams may reduce risk with a blue green release, which keeps two copies of production and switches users from one to the other, or a canary release, which sends a small share of users to the new version first.

Benefits

  • Faster releases in small steps.
  • Fewer manual mistakes.
  • The same steps run the same way each time.
  • Early detection of faults.
  • An easy way to roll back to an earlier artifact.

DevOps principles

DevOps joins development and operations so that they share responsibility from idea to running service. Its main principles are:

  • Collaboration. Teams share goals and tools, and remove the wall between building and running.
  • Automation. Builds, tests, deployments and infrastructure are scripted and repeatable.
  • Continuous integration and delivery. Small changes flow to production often.
  • Monitoring and feedback. Metrics and logs show how the service behaves, and the findings guide the next change.
  • Continuous improvement. Teams learn from failures without blame and refine their process.
  • Infrastructure as code. Environments are described in files and kept under version control.

DevOps grew out of agile and lean ideas. The common summary is that you build it, and you run it.

Exam tip

Delivery versus deployment is about the last step. In delivery a person presses the button. In deployment the pipeline does it automatically.

What to remember for the exam

Seven facts cover this topic.

  • CI merges code often and runs an automatic build and test on each merge.
  • Continuous delivery keeps every passing change ready to release, with a manual approval.
  • Continuous deployment releases every passing change automatically.
  • Typical stages are source, build, test, artifact storage, deploy and monitor.
  • A pipeline is often defined as code in a file in the repository.
  • DevOps stresses collaboration, automation, feedback and continuous improvement.
  • Blue green and canary releases reduce the risk of a new version.

Common mistakes

Four mistakes are typical.

Mixing up delivery and deployment. Delivery needs a human decision to release. Deployment does not.

Skipping automated tests. A pipeline without tests only moves bugs faster.

Treating DevOps as a tool. It is a way of working, and tools support it.

Rebuilding for every environment. Build one artifact, then promote that same artifact through each environment.

Watch out

Keep secrets such as passwords and tokens out of pipeline files that live in the repository. Use the secret store of the pipeline tool.

Check yourself

Work through these three questions.

  • What is the difference between continuous delivery and continuous deployment?

    Delivery leaves the final release to a manual approval, while deployment releases every passing change automatically.

  • What does a CI build do when a developer merges code?

    It builds the code and runs the automated tests, so problems are found quickly.

  • Which three DevOps principles can you name?

    Collaboration, automation and continuous feedback and improvement.

Topic 3 of 8 in Application Deployment and Security

Test yourself on Application Deployment and Security

The full Cisco CCNA 200-901 DEVASC question bank has 808 questions, with timed practice exams and an explanation for every answer.

This study guide is independent and is not affiliated with, endorsed by, or sponsored by Cisco. Vendor names, certification names and exam codes are trademarks of their respective owners and are used for identification only.