OpsGenie - Harness

Hey All!

I’ve had a few conversations around integrations with Harness and other tools, what is and is not supported, and even when specific integrations will be coming. One of the great things about a Software-as-a-Service like Harness is that you get rapid integration support with use-case-directed development.

We will need to supplement a stop-gap for some of these integrations in the meantime. The technology integration that this post covers will be Atlassian OpsGenie.

For those who might want something quick and easy, there is a way to do Email notifications in OpsGenie.

For those who want something more robust, here are the steps to get a webhook working that auto-closes the ticket upon a successful failure strategy.

Atlassian OpsGenie Team Webhook

The first step is to add an API Webhook to your OpsGenie Team:


Secrets Management

Once you have the API Key for the integration, you’ll want to make a secret called “ops-genie-token” in the Harness Secrets Manager.

Template Library

The next step in the process is to create two new templates in the Template Library:

  1. Create Alert
    a. Name: “opsgenie-create-alert”
    b. Script: git repo
    c. Script Output: ALIAS
    d. Variables: MSG

  2. Close Alert
    a. Name: “opsgenie-close-alert”
    b. Script: git repo
    c. Variable: ALIAS

Workflow Integration

Considering OpsGenie is more of an incident/on-call solution (similar to PagerDuty), the only time a notification would be required is when a failed deployment goes out to a production environment. In this case, we will want to bookend the failure strategy by OpsGenie Create Alert and OpsGenie Close Alert. This allows us to know if the failure strategy was successful or not (the alert would still be open if the failure strategy encountered an error). For this post, we will look at Custom Rollback Steps.

In the main deployment phase, link the OpsGenie Create Alert template at the top of the rollback steps, and the OpsGenie Close Alert template will go at the bottom.

The last piece to put together is in the template steps in the workflow. For the OpsGenie Create Alert template, make sure that you do the following:

  1. Check the box for “Publish output in the Context”

  2. Publish Variable Name = “ops”

  3. Scope: Workflow

  4. Add the desired message to the MSG variable:

  5. Example: ALERT: Service ${service.name} in application ${app.name} failed during ${env.name}:${infra.name} deployment! Rollback is executing. Wait for Rollback Success Alert

Lastly, in the OpsGenie Close Alert template, make sure you do the following:

  1. Add “${ops.ALIAS}” to the ALIAS Variable

Workflow Execution

To test this out, I added a rolling deployment with an HTTP Check step that will fail after the deployment succeeds:

That is all it takes to add an OpsGenie integration into your deployment process!

I will update this post as some functionality is improved or if new issues arise.

Don’t forget to Comment/Like/Share!