CircleCI

This guide uses the CircleCI Cloud version.

This guide will show you how you can add Reliably to your CircleCI build as a CircleCI job.

Set up a project in CircleCI

Once your logged into CircleCI, set up a new project or select a project already building on CircleCI.

Making a project run on CircleCI requires a configuration file located at .circleci/config.yml.

Setup your Reliably access token as environment variable

The CLI must be run with a valid access token to make authenticated calls to Reliably.

As a prerequisite, the RELIABLY_TOKEN must be defined as a secret environment variable in your project’s settings; See how to [set an environment variable in a project] (https://circleci.com/docs/2.0/env-vars/#setting-an-environment-variable-in-a-project).

Define Reliably token as CircleCI env variable

You can see how to retrieve your access token.

Setup your Reliably organization as environment variable

You shall define the organization to work on, when using the CLI, by defining the RELIABLY_ORG as an environment variable.

To retrieve your currently active organization, run: reliably org current.

You can use either the organization ID or name as RELIABLY_ORG value.

If not specified, the logged in user's default organization will be used.

Create the Reliably job

We will now define Reliably as a job, before adding it to a new or existing workflow.

This is how CircleCI defines a job, in YAML:

<job name>
  <executor>
  <steps>

We will name our job agent, as we want to run the reliably graph agent command.

The executor will be a Docker image of Reliably, which we want to run in the /home directory.

Our job will be made of one single step:

  • Run the reliably graph agent command

Here is our completed job:

agent:
  docker:
    - image: ghcr.io/reliablyhq/cli/cli:latest
      environment:
        RELIABLY_TOKEN: $RELIABLY_TOKEN
  working_directory: /home
  steps:
    - run: reliably graph agent

Add the job to a workflow

This is how CircleCI defines a workflow, in YAML:

<workflow name>
  jobs
    <optional triggers>
    <job name>

We will create a reliably workflow, with a single job, agent.

reliably:
  jobs:
    - agent

Final config.yml file

The most simple file CircleCI configuration file will then look like this:

version: 2.1
jobs:
  agent:
    docker:
      - image: ghcr.io/reliablyhq/cli/cli:latest
        environment:
          RELIABLY_TOKEN: $RELIABLY_TOKEN
          RELIABLY_ORG: $RELIABLY_ORG
    working_directory: /home
    steps:
      - run: reliably graph agent

workflows:
  when:
    and:
      - equal: [ scheduled_pipeline, << pipeline.trigger_source >> ]
  reliably:
    jobs:
      - agent

Commit this file to your repository and go back to your project in CircleCI Cloud. You should now add a scheduled pipeline to run this workflow at regular interval.

Congratulations, you now integrated Reliably into your CircleCI build!