Connect your CircleCI Pipeline to Humanitec with an Orb

Overview

This how-to guide explains how to connect your CircleCI Pipeline with a Circle CI Orb to Humanitec to retrieve your container images from your repositories.

Here is a short video explaining how to connect your CircleCI Pipeline and Humanitec.

The Humanitec Orb

Humanitec is providing a CircleCI Orb Humanitec that is available from the CircleCI Orb Registry. Using this CircleCI Orb allows for a simple and convenient integration between CircleCI and Hunmanitec.

Create a new pipeline

If you do not have a CircleCI Pipeline set up, you will need to create one.

  1. Go to the Git Repository you want to connect.
  2. Create a new folder called .circleci.
  3. Create a new file called config.yml.
  4. The new file look like this, where YOUR-HUMANITEC-ORGANIZATION is the name of your organization in Humanitec:


# Use the latest 2.1 version of CircleCI pipeline process engine. See: https://circleci.com/docs/2.0/configuration-reference
version: 2.1
# Use a package of configuration called an orb.
orbs:
  humanitec: humanitec/[email protected]
# Orchestrate or schedule a set of jobs
workflows:
  build-push-and-notify-humanitec:
    jobs:
      - humanitec/build-push-and-notify-humanitec:
          organization: YOUR-HUMANITEC-ORGANIZATION

Note that you will need to commit this file to your Git repository and establish a connection between the repository and your CircleCI account. Follow the explanations in the CircleCI app to create the connection. You will need to have third-party orbs support enabled in your Organization Settings in CircleCI.

Add token to the CircleCI project

In order to finalize the connection between CircleCI and Humanitec, you will need to add a token to the CircleCI project. This requires the following steps:

  1. Log in to Humanitec.
  2. Click the profile icon in the top right.
  3. Select Organization Settings.
  4. Select the Images tab.
  5. Click the CircleCI button.

From there, Humanitec will provide you with an access token for connecting to Humanitec’s registry. Instructions will appear in the modal.

First, add the token as an Environment Variable in your CircleCI project:

  1. Go to the project you want to connect.
  2. Go to Project Settings, and then go to Environment Variables > Add Variable.
  3. Create a variable called HUMANITEC_TOKEN, and paste the token from the modal as the value.

Then, add the snippet from the modal to the end of your config.yml file and commit the changes.

The last step is trigger a build of your image. If the build is successful, then your image will become available on Humanitec as a module that can be added to your environments.