---
title: validated-builds-using-circleci-ci-cd - Codenotary
description: MONITOR & MANAGE THE RISK EXPOSURE OF YOUR APPLICATIONS WITH TRUESBOM®
image: https://codenotary.com/hubfs/Imported_Blog_Media/Blog-Default-MnL-Feb-06-2023-03-57-27-8655-PM.jpg
---

**$ protect --distro linux --machines 25 --free**

[Start now](https://apps.codenotary.com/linux)

[![cn-logo-black-nobg](https://codenotary.com/hubfs/cn-logo-black-nobg.svg)](https://codenotary.com/)

- Product
  
  #### [![AgentMon Start](https://codenotary.com/hubfs/chub_backup/AgentMon%20Start.svg) **AgentMon Start** See what your AI agents are doing on your machine. TRY NOW →](https://codenotary.com/agentmon-start)
  
  #### [![AgentMon for Enterprise](https://codenotary.com/hubfs/AgentMon%20for%20Enterprise.svg) **AgentMon** Currently monitors more \> 7 million agent interactions/day. TRY NOW →](https://codenotary.com/agentmon)
  
  #### [![AgentX](https://codenotary.com/hubfs/AgentX.svg) **AgentX** Agentic network control middleware. TRY NOW →](https://codenotary.com/agent-network-control)
  
  #### [![Autonomous Security](https://codenotary.com/hubfs/Autonomous%20Security.svg) **Autonomous Security** AI Agents keep your servers secure. TRY NOW →](https://codenotary.com/trust)
- Use Cases
  
  #### [**AI Agent Risk Monitoring** Continuous oversight of autonomous agents across every environment.](https://codenotary.com/use-cases#risk)
  
  #### [**Autonomous Security Operations** Self-healing defenses that detect, contain, and remediate threats.](https://codenotary.com/use-cases#agentops)
  
  #### [**AI Coding Governance & Performance Monitoring** AI-generated code reviewed, tracked, and held to quality standards.](https://codenotary.com/use-cases#performance)
  
  #### [**AI Tool Cost & Usage Optimization** Spend and consumption optimized across every AI service in use.](https://codenotary.com/use-cases#cost)
  
  #### [**AI Tool Security & Policy Enforcement** Approved AI usage enforced with guardrails and policy controls.](https://codenotary.com/use-cases#security#security)
  
  #### [**Shadow AI Governance** Unsanctioned AI tools discovered, surfaced, and brought under control.](https://codenotary.com/use-cases#shadowit)
- [Blog](https://codenotary.com/blog)
- [Press](https://codenotary.com/press)
- Resources
  
  #### [**Integrations** Connect with your favorite tools and platforms. LEARN MORE →](https://codenotary.com/integrations)
  
  #### [**Support** Get help from our dedicated support team. GET HELP →](https://support.codenotary.com)
  
  #### [**Success Stories** Read how customers achieve their goals. READ MORE →](https://codenotary.com/success)
  
  #### [**Learn** Access documentation and learning resources. EXPLORE →](https://codenotary.com/learn)

[Login](https://apps.codenotary.com/auth/login)

[All posts](https://codenotary.com/blog/all)

 Nov 08, 2019

# validated-builds-using-circleci-ci-cd

 By  [Dennis](https://codenotary.com/blog/author/dennis)  ·   4 minute read

As [CircleCI](https://circleci.com/) is one of the most popular CI/CD tools in the market, it was no surprise to us that we got plenty of requests lately. Users were noticing the [Jenkins](https://www.Codenotary.io/blog/securing-your-azure-devops-ecosystem-jenkins-and-kubernetes-aks-using-Codenotary-part-1/) integration in our blog posts and we’re wondering how the CircleCI would look like.

We listened and here comes the CircleCI integration to produce validated builds that can be verified and authenticated by anyone from everywhere.

Our blog post covers all steps required to produce a validated build:

- Fork an existing Git repository as an example
- Creation of the Circle CI config
- Define the Circle CI build steps 
    - Download the latest Codenotary vcn command line
    - Authenticate the downloaded binary (better safe than sorry)
    - Build the docker image
    - Notarize the docker image including the Circle CI build number
    - Deploy the docker image to Dockerhub
- Validate the uploaded docker image

## Setup

### Create or Fork a repository

Let’s start with the setup of our git repository, that contains a fork of a simple static website project. <https://github.com/katacoda/golang-http-server>[https://github.com/katacoda/golang-http-server](https://github.com/katacoda/golang-http-server)

For our example its important that the repo contains a valid Dockerfile to build the container image.

After we forked that project we need to add the Circle CI build configuration.

### Create Circle CI config

To do so, simply create the file config.yml within the .circleci folder in the forked repository.

![](https://codenotary.com/hubfs/Imported_Blog_Media/repo-1024x497-1.png)

### Define the Circle CI steps to create a validated build

The content of that config.yml file contains all the required steps to build:

General build setup

```
version: 2
jobs:
  build:
    docker:
      - image: golang:1.13.4-stretch
    environment:
      TEST_RESULTS: /tmp/test-results
    steps:
      - checkout
      - setup_remote_docker
```

#### Prepare the remote docker client

```
# This should go into custom primary image, here's only for the sake of explanation
      - run:
          name: Install Docker client
          command: |
            set -x
            VER="17.03.0-ce"
            curl -L -o /tmp/docker-$VER.tgz https://get.docker.com/builds/Linux/x86_64/docker-$VER.tgz
            tar -xz -C /tmp -f /tmp/docker-$VER.tgz
            mv /tmp/docker/* /usr/bin
```

Download the latest Codenotary vcn command line

```
      - run:
          name: Download Codenotary vcn binary
          command: |
            set -x
            VER="v0.7.3"
            curl -L -o /tmp/vcn https://github.com/vchain-us/vcn/releases/download/v0.7.3/vcn-$VER-linux-amd64
            CHECKSUM=$(sha256sum /tmp/vcn | cut -d " " -f 1)
            curl -s https://api.Codenotary.io/authenticate/$CHECKSUM?org=vchain.us | grep -q :0
```

The important pieces of that code snippets are the download of the latest version (please make sure to change the version accordingly), an independent calculation of the file checksum to do a validation. The [Codenotary](https://www.Codenotary.io) validation makes sure, that the downloaded binary has really been notarized by [vchain.us](https://www.vchain.us) the maker of the vcn cli:

```
curl -s https://api.Codenotary.io/authenticate/$CHECKSUM?org=vchain.us | grep -q :0
```

The exit code is always 0 (success), when the checksum can be validated and has been notarized by a given organization.

**That way, we can validate that we’re not going to use a faked or tampered vcn!** The pipeline breaks, if no validation is possible.

#### Move the vcn binary into the path and make it executable

```
      - run:
          name: move Codenotary vcn binary
          command: |
            chmod +x /tmp/vcn
            mv /tmp/vcn /usr/local/bin/vcn
```

#### Build the docker image

```
      - run:
          name: Build Docker image
          command: |
            TAG="0.1.${CIRCLE_BUILD_NUM}"
            docker build -t Codenotarydemo/demowebserver:$TAG .
```

#### Notarize the docker image including the Circle CI build number

```
      - run:
          name: Notarize Docker image
          command: |
            TAG="0.1.${CIRCLE_BUILD_NUM}"
            VCN_USER=${Codenotary_user} VCN_PASSWORD=${Codenotary_pass} vcn login
            VCN_NOTARIZATION_PASSWORD=${Codenotary_pass} vcn n --attr CircleCI=$TAG docker://Codenotarydemo/demowebserver:$TAG 
```

This job makes sure the docker image is notarized before uploaded the Dockerhub, so nobody could intervene. For additional security, we add the CircleCI build number as well to the notarization process.

Please be aware, that we use different environment variables in that step that need to be defined in Circle CI.

![validated builds - Circle CI environment variables](https://codenotary.com/hubfs/Imported_Blog_Media/envvar-1024x542-1.png)

#### Deploy the docker image to Dockerhub

```
      - run:
          name: Push Docker image
          command: |
            TAG="0.1.${CIRCLE_BUILD_NUM}"
            docker login -u ${docker_user} -p ${docker_pass}
            docker push Codenotarydemo/demowebserver:$TAG
```

Our last step of the pipeline makes sure the newly build docker container image is uploaded to our DockerHub.com repository using the correct tag. Please make sure to set the Circle CI environment variables for DockerHub as well.

![validated build on dockerhub](https://codenotary.com/hubfs/Imported_Blog_Media/dockerhub-1024x603-1.png)

## Result

Let’s put all pieces together to a complete build flow for Circle CI (.circleci/config.yml)

```
version: 2
jobs:
  build:
    docker:
      - image: golang:1.13.4-stretch
    environment:
      TEST_RESULTS: /tmp/test-results

    steps:
      - checkout
      - setup_remote_docker

      # This should go into custom primary image, here's only for the sake of explanation
      - run:
          name: Install Docker client
          command: |
            set -x
            VER="17.03.0-ce"
            curl -L -o /tmp/docker-$VER.tgz https://get.docker.com/builds/Linux/x86_64/docker-$VER.tgz
            tar -xz -C /tmp -f /tmp/docker-$VER.tgz
            mv /tmp/docker/* /usr/bin

      - run:
          name: Download Codenotary vcn binary
          command: |
            set -x
            VER="v0.7.3"
            curl -L -o /tmp/vcn https://github.com/vchain-us/vcn/releases/download/v0.7.3/vcn-$VER-linux-amd64
            CHECKSUM=$(sha256sum /tmp/vcn | cut -d " " -f 1)
            curl -s https://api.Codenotary.io/authenticate/$CHECKSUM?org=vchain.us | grep -q :0

      - run:
          name: Authenticate and move Codenotary vcn binary
          command: |
            chmod +x /tmp/vcn
            mv /tmp/vcn /usr/local/bin/vcn

      - run:
          name: Build Docker image
          command: |
            TAG="0.1.${CIRCLE_BUILD_NUM}"
            docker build -t Codenotarydemo/demowebserver:$TAG .

      - run:
          name: Notarize Docker image
          command: |
            TAG="0.1.${CIRCLE_BUILD_NUM}"
            VCN_USER=${Codenotary_user} VCN_PASSWORD=${Codenotary_pass} vcn login
            VCN_NOTARIZATION_PASSWORD=${Codenotary_pass} vcn n --attr CircleCI=$TAG docker://Codenotarydemo/demowebserver:$TAG 

      - run:
          name: Push Docker image
          command: |
            TAG="0.1.${CIRCLE_BUILD_NUM}"
            docker login -u ${docker_user} -p ${docker_pass}
            docker push Codenotarydemo/demowebserver:$TAG
```

When all went well, you should see the build process starting with your config.yml change and everything running through.

![Circle CI build successful](https://codenotary.com/hubfs/Imported_Blog_Media/pipeline-1024x721-1.png)

## Validate the uploaded docker image

As this run was the first to happen, let’s make sure the notarization of the image went well and anyone in the world is able to validate the build.

Therefore, lets pull the uploaded image to a complete different system and use [vcn to authenticate all information](https://github.com/vchain-us/vcn).

**docker pull Codenotarydemo/demowebserver:0.1.4**

**vcn authenticate docker://Codenotarydemo/demowebserver:0.1.4**

![validate build using vcn](https://static.hsstatic.net/BlogImporterAssetsUI/ex/missing-image.png)

All checks were successful and we’re sure to not release any software, container image or other artifact that cannot be validated.

If you’re serious about security, DevSecOps and build validation, there is no excuse anymore as its free:

[Sign Up for build validation](https://dashboard.Codenotary.io/auth/signup)

[![Share on twitter](https://4059529.fs1.hubspotusercontent-na1.net/hub/4059529/hubfs/01-marketplace/twitter-color.png?width=35&height=35&name=twitter-color.png)](https://twitter.com/intent/tweet?original_referer=https://codenotary.com/blog/validated-builds-using-circleci-ci-cd&utm_medium=social&utm_source=twitter&url=https://codenotary.com/blog/validated-builds-using-circleci-ci-cd&utm_medium=social&utm_source=twitter&source=tweetbutton&text=) [![Share on facebook](https://4059529.fs1.hubspotusercontent-na1.net/hub/4059529/hubfs/01-marketplace/facebook-color.png?width=35&height=35&name=facebook-color.png)](http://www.facebook.com/share.php?u=https://codenotary.com/blog/validated-builds-using-circleci-ci-cd&utm_medium=social&utm_source=facebook) [![Share on linkedin](https://4059529.fs1.hubspotusercontent-na1.net/hub/4059529/hubfs/01-marketplace/linkedin-color.png?width=35&height=35&name=linkedin-color.png)](http://www.linkedin.com/shareArticle?mini=true&url=https://codenotary.com/blog/validated-builds-using-circleci-ci-cd&utm_medium=social&utm_source=linkedin) [![Share on pinterest](https://4059529.fs1.hubspotusercontent-na1.net/hub/4059529/hubfs/pinterest.jpg?width=35&height=35&name=pinterest.jpg)](http://pinterest.com/pin/create/button/?url=https://codenotary.com/blog/validated-builds-using-circleci-ci-cd&utm_medium=social&utm_source=pinterest&media=)

```json
{
  "@context" : "https://schema.org",
  "@type" : "BlogPosting",
  "author" : {
    "@type" : "Person",
    "name" : "Dennis",
    "url" : "https://codenotary.com/blog/author/dennis"
  },
  "dateModified" : "2023-02-14T21:22:51.121Z",
  "datePublished" : "2019-11-08T22:41:36.000Z",
  "headline" : "validated-builds-using-circleci-ci-cd - Codenotary",
  "image" : [ "https://codenotary.com/hubfs/Imported_Blog_Media/Blog-Default-MnL-Feb-06-2023-03-57-27-8655-PM.jpg" ],
  "mainEntityOfPage" : {
    "@id" : "https://codenotary.com/blog/validated-builds-using-circleci-ci-cd",
    "@type" : "WebPage"
  },
  "publisher" : {
    "@type" : "Organization",
    "logo" : {
      "@type" : "ImageObject",
      "url" : "https://codenotary.com/hubfs/logo-light.svg"
    },
    "name" : "Codenotary, Inc."
  }
}
```

```json
{
  "@context" : "http://schema.org",
  "@type" : "Article",
  "author" : {
    "@type" : "Person",
    "name" : [ "Dennis" ],
    "url" : "https://codenotary.com/blog/author/dennis"
  },
  "datePublished" : "2019-11-08T22:41:36+0000",
  "description" : "MONITOR & MANAGE THE RISK EXPOSURE OF YOUR APPLICATIONS WITH TRUESBOM®",
  "headline" : "validated-builds-using-circleci-ci-cd",
  "image" : "https://cdn2.hubspot.net/hubfs/23873599/Imported_Blog_Media/Blog-Default-MnL-Feb-06-2023-03-57-27-8655-PM.jpg",
  "publisher" : {
    "@type" : "Organization",
    "logo" : {
      "@type" : "ImageObject",
      "url" : "https://cdn2.hubspot.net/hubfs/23873599/logo-light.svg"
    },
    "name" : ""
  },
  "url" : "https://codenotary.com/blog/validated-builds-using-circleci-ci-cd"
}
```