CircleCI integration with container registries
Published: 2019-12-11 12:41:38

[CircleCI](https://circleci.com/)  is a cloud-based continuous integration and delivery platform, It’s free for open-source repositories and supports most languages. From version 2.1, CircleCI supports [orbs](https://circleci.com/docs/2.0/orb-intro/), that are shareable packages of configuration elements, including jobs, commands, and executors. Therefore we don’t need to reinvent the wheel as we can easily use the [artifactory-orb](https://circleci.com/orbs/registry/orb/jfrog/artifactory-orb) which contains the [JFrog CLI](https://www.jfrog.com/confluence/display/CLI/JFrog+CLI) to store our build artifacts for future distribution in our Docker Container Registry. In this blog, I will show you how to use CircleCI by using a private JFrog Container Registry to store your builds, artifacts, and build information.

Let’s take a closer look at how this actually works. The following example describes how to easily configure CircleCI to push Docker builds as artifacts to JFrog container registry using orbs.
Step 1: Clone the sample repository
Create a repository in GitHub and clone this [sample GitHub project](https://github.com/BatelT/circleci-docker-example) into your git repository.
Step 2: Create the CircleCI configuration files
In this example, we use the artifactory-orbs to download the JFrog CLI to perform thee following under the hood:


{% runkit%}

Description: Install the JFrog CLI
Steps:
 - run:
      command: |
        echo "Checking for existence of CLI"
        set +e
        jfrog -v
        if [ $? -gt 0 ]; then
          echo "Not found, installing latest"
          curl -fL https://getcli.jfrog.io | sh
          chmod a+x jfrog && sudo mv jfrog /usr/local/bin
        else
          echo "CLI exists, skipping install"
        fi
      name: Install JFrog CLI

{% endrunkit %}

This is the full config file.:

{% runkit%}
orbs:
  artifactory: circleci/artifactory@1.0.0
version: 2.1
workflows:
  simple-docker-example:
    jobs:
      - artifactory/docker-publish:
          docker-registry: batelt-docker.jfrog.io
          docker-tag: 'batelt-docker.jfrog.io/hello-world:1.0-${CIRCLE_BUILD_NUM}'
          name: Docker Publish Simple
          repository: docker-local
{% endrunkit %}

Here also in the background, we are using the [ Building Docker Images](https://www.jfrog.com/confluence/display/CLI/CLI+for+JFrog+Artifactory#CLIforJFrogArtifactory-BuildingDockerImages)commands via the JFrog CLI.
Step 3: Enable Pipelines
To orbs, we have to enable Pipelines via the UI under  Project Settings -> Advanced Settings as follows.
![Enable Pipelines](https://i.ibb.co/fMymzBt/Project-settings-Batel-T-circleci-docker-example-Circle-CI.jpg)
Step 4: Configure the environment variables
Enable your project build in CircleCI by adding the following variables to your build settings:
ARTIFACTORY_URL 
ARTIFACTORY_USERNAME
ARTIFACTORY_API_KEY
![Configure the environment variables](https://i.ibb.co/L83Pf8Y/Project-settings-Batel-T-circleci-docker-example-Circle-CI.jpg)
Step 5: View your build in the JFrog Container Registry 
You can now view build in details in the JFrog Container Registry[Build Browser.](puthttps://www.jfrog.com/confluence/display/jcr/Build+Integration#BuildIntegration-InspectingBuilds) Click any build to drill down and view all the build info that the JFrog Container Registry captures.
![View your build](https://i.ibb.co/nLyqdMR/TOdt-U3-A5-Wy.gif)


Great! That’s it. You have successfully completed integrating the JFrog Container Registry in CircelCI done.