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.

​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 is success in Circle CI, an alert is created in OpsGenie automatically through the integration.
  • When the outcome is not successful in Circle CI, the alert created in OpsGenie is closed automatically.

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.
  3. Specify who is notified of CircleCI alerts using the Teams field. Auto-complete suggestions are provided as you type.
  4. Copy the integration API key to use in CircleCI configuration.
  5. Click Save Integration.

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": "luke@krypton.io",
      "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": "lukebayes@gmail.com",
    "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": "lukebayes@gmail.com"
  }
}

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": "lukebayes@gmail.com",
  "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

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.