CircleCI Integration

CircleCI is a continuous integration and deployment solution that offers fast and smart testing. Opsgenie is an alert and notification management solution that is highly complementary to CircleCI.

360

​What does Opsgenie offer CircleCI users?

Opsgenie has a specific API integration with CircleCI. CircleCI sends build results to Opsgenie API, with detailed information. Opsgenie is a dispatcher for CircleCI build failures; determines the right people to notify based on on-call schedules– notifies via email, text messages (SMS), phone calls and iPhone & Android push notifications, and escalates alerts until the alert is acknowledged or closed.

Functionality of the integration

  • When the outcome does not equal success in Circle CI, an alert is created in Opsgenie automatically through the integration.
  • When the outcome equals success in Circle CI, the corresponding alert in Opsgenie, if one exists, is closed automatically through the integration.

Add CircleCI integration in Opsgenie

  1. Please create an Opsgenie account if you haven't done so already.
  2. Go to Opsgenie CircleCI Integration page.

🚧

For Free and Essentials plans, you can only add the integrations from the Team Dashboards, please use the alternative instructions given below to add this integration.

  1. Specify who is notified of CircleCI alerts using the Teams field. Auto-complete suggestions are provided as you type.

📘

An alternative for Step 2) and Step 3) is to add the integration from the Team Dashboard of the team which will own the integration. To add an integration directly to a team, navigate to the Team Dashboard and open Integrations tab. Click Add Integration and select the integration that you would like to add.

  1. Copy the integration API key to use in CircleCI configuration.
  2. Click Save Integration.
2155

Configuration in CircleCI

  1. Add the following configuration to your circle.yml file:
notify:
                webhooks:
                    - url: https://api.opsgenie.com/v1/json/circleci?apiKey=${API_KEY}

where ${API_KEY} is the integration API key you copied earlier.

Sample payload sent from Circle CI

Create Alert payload:

{
  "payload": {
    "compare": "https://github.com/kr-project/experimental/compare/8484cc4a96cf...a760ee54f155",
    "previous_successful_build": {
      "build_num": 27233,
      "status": "success",
      "build_time_millis": 246809
    },
    "build_parameters": null,
    "oss": false,
    "committer_date": "2015-12-10T13:55:35-08:00",
    "body": "",
    "usage_queued_at": "2015-12-10T21:55:52.543Z",
    "retry_of": null,
    "reponame": "experimental",
    "ssh_users": [],
    "build_url": "https://circleci.com/gh/kr-project/experimental/27237",
    "parallel": 2,
    "failed": null,
    "branch": "lbj-circle",
    "username": "kr-project",
    "author_date": "2015-12-10T13:55:35-08:00",
    "why": "github",
    "user": {
      "is_user": true,
      "login": "lukebayes",
      "name": "Luke Bayes",
      "email": "[email protected]",
      "avatar_url": "https://avatars.githubusercontent.com/u/4817?v=3"
    },
    "vcs_revision": "a760ee54f1551d606f3a0803ed64963a900a6a0a",
    "owners": [
      "lukebayes"
    ],
    "vcs_tag": null,
    "build_num": 27237,
    "infrastructure_fail": false,
    "ssh_enabled": false,
    "committer_email": "[email protected]",
    "previous": {
      "build_num": 27234,
      "status": "failed",
      "build_time_millis": 256466
    },
    "status": "fixed",
    "committer_name": "Luke Bayes",
    "pull_request_urls": [
      "https://github.com/kr-project/experimental/pull/3175"
    ],
    "retries": null,
    "subject": "Test integration with OpsGenie support",
    "timedout": false,
    "dont_build": null,
    "lifecycle": "finished",
    "no_dependency_cache": null,
    "stop_time": "2015-12-10T22:04:11.461Z",
    "build_time_millis": 382714,
    "messages": [
      {
        "type": "warning",
        "message": "Warning: CircleCI has located an Xcode project or workspace in this repository. CircleCI is currently offering limited release to our iOS build system. Please contact support if you would like access."
      }
    ],
    "is_first_green_build": false,
    "job_name": null,
    "start_time": "2015-12-10T21:57:48.747Z",
    "canceler": "talcami",
    "outcome": "success",
    "vcs_url": "https://github.com/kr-project/experimental",
    "author_name": "Luke Bayes",
    "queued_at": "2015-12-10T21:57:48.711Z",
    "canceled": false,
    "author_email": "[email protected]"
  }
}

This payload is parsed by Opsgenie as:

{
  "repo_name": "experimental",
  "build_url": "https://circleci.com/gh/kr-project/experimental/27237",
  "branch": "lbj-circle",
  "subject": "Test integration with Opsgenie support",
  "build_number": 27233,
  "build_time_millis": 246809,
  "canceled": false,
  "canceler": "talcami",
  "committer_email": "[email protected]",
  "committer_name": "Luke Bayes",
  "committer_date": "2015-12-10T13:55:35-08:00",
  "start_time": "2015-12-10T21:57:48.747Z",
  "stop_time": "2015-12-10T22:04:11.461Z",
  "ssh_enabled": false,
  "why": "github"
}

Sample alert

2433