Jenkins Build

Adding Reliably to your Jenkins build is as simple as adding a job to Jenkins.

Prerequisites

To run Reliably as a Jenkins Job you will need access to a Jenkins server.

Create a Reliably Project in Jenkins

Navigate to your Jenkins server home page:

Jenkins Homepage

The above screenshot is for a newly installed Jenkins server. A server that has previously run jobs would show the jobs dashboard on the Jenkins home page.

Selected New Item from the menu on the left of the page.

Jenkins New Build

Enter an item name (e.g. Run Reliably). Select the Freestyle project option, then select OK.

Setup Reliably access token

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 an environment variable.

It requires the Environment Injector plugin to be installed.

In the new job display that appears next select the Build Environment tab, then select Inject passwords to the build as environment variables, and click Add under Job passwords. Type RELIABLY_TOKEN in the name field and paste your access token in the password field.

You can see how to retrieve your access token.

Inject Reliably token as env var

Setup your Reliably organization

You shall define the organization to work on, when using the CLI, by defining RELIABLY_ORG as 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.

Add Reliably as a Build step

In the new job display that appears next select the Build tab, then select Execute Shell from the Add Build Step dropdown menu

In the command window enter these commands:

curl -s -L https://github.com/reliablyhq/cli/releases/latest/download/reliably-linux-amd64 -o reliably
chmod u+x reliably
./reliably graph agent

What does this do?

  • The Reliably latest release is downloaded from Github.
  • The binary is given execute permissions.
  • Finally, the reliably graph agent command is run and update objectives accordingly.

Select Save

In the menu for the project:

  • Select the Build Now option
  • Select the resulting Job that appears at the bottom of the menu.
  • Select the Console Output for the Job, you should see the agent’s output.

Congratulations you have successfully run Reliably as part of a Jenkins build!