• Products
  • Get started
  • Documentation
  • Resources

Integrate Opsgenie with Jenkins

Jenkins logo

What does Opsgenie offer Jenkins users?

Use Opsgenie Jenkins Integration to forward Jenkins build alerts to Opsgenie. Opsgenie determines the right people to notify based on on-call schedules– notifies via email, text messages (SMS), phone calls, and iOS & Android push notifications, and escalates alerts until the alert is acknowledged or closed.

Functionality of the integration

When a build related problem occurs in Jenkins, an alert is created in Opsgenie automatically through the integration.

Add Jenkins Integration to Opsgenie

If you're using Opsgenie's Free or Essentials plan or if you’re using Opsgenie with Jira Service Management's Standard plan, you can add this integration from your team dashboard only. The Integrations page under Settings is not available in your plan.

  1. Go to Teams and select your team.

  2. Select Integrations on the left navigation and then select Add integration.

Adding the integration from your team dashboard will make your team the owner of the integration. This means Opsgenie will assign the alerts received through this integration to your team only. Follow the rest of the steps in this section to set up the integration.

  1. Go to Settings > Integrations. Search for Jenkins and select Add

  2. Specify who is notified of Jenkins alerts using the Responders field. Auto-complete suggestions are provided as you type.

  3. Copy the URL and API Key and paste it into plugin's "Opsgenie Api URL" and "API Key" fields respectively.

  4. Select Save Integration.

Install and Configure Opsgenie Jenkins Plugin

  1. In the Jenkins machine go to "Manage Jenkins" -> "Go to plugin manager" -> "Available" and search for Opsgenie Plugin, select and install it.

  2. Go back to Jenkins main page and go to "Manage Jenkins" -> "Configure System" -> "Opsgenie Notifier Settings" in order to set Global Plugin Configuration.

  3. Global Settings:

Jenkins global settings
  • Enter the API URL and API Key that's given from Opsgenie Jenkins Integration. API URL is set to a default value but also can be configured.

  • Enter the Teams to notify and alert Tags.

  • These fields are used as default settings, override them for specific jobs.

4. Post-Build Action:

Jenkins post build action
  • Activate Opsgenie Plugin for the Jenkins Job by following -> "Configure".

  • Scroll to the "Post-Build Actions" section of the project configuration.

  • Click "Add post-build action".

  • Select "Send Alert to Opsgenie" from the list displayed. The "Send Alert to Opsgenie" section appears in the window.

  • Click Save to retain these changes.

5. Job Configuration:

Jenkins job configuration
  • Configure the Jenkins Job settings for Opsgenie plugin by following -> "Configure" -> "Send Alert to Opsgenie".

  • Check "Enable Sending Alerts" to send an alert to Opsgenie.

  • Check "Notify Build Start" to send an alert to Opsgenie that notifies on build start.

  • Enter the API URL and API Key that's given from Opsgenie Jenkins Integration. If these fields are filled, global settings are overridden.

  • Enter the Teams to notify and alert Tags. Fill these fields to override global settings.

  • Select the priority of the build status alert from "Priority" field.

  • Select the priority of the build start status alert from "Build Start Alert's Priority" field.

6. For more information about plugin you can check Opsgenie Plugin and our open source project Opsgenie Jenkins Plugin

Opsgenie Step Function Configuration

You can call Opsgenie Trigger Step function from your pipeline stages or post actions. Opsgenie Step function can be called with the following parameters(or without any parameter): tags(comma separated), teams(comma separated), priority, apiKey and apiUrl
An example request would be the following:


1 opsgenie(tags: "tag1,tag2" , teams: "team1", priority: "P1")

API key and API Url

You can configure API key and API url from Manage Jenkins -> Configure System -> Opsgenie Notifier Settings.
You can also override API key and API url from the step function call like following: opsgenie(apiKey: "myApiKey", apiUrl: "myApiUrl")

An example pipeline script:


1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 pipeline { agent any stages { stage('pre') { steps { sh 'echo "pre success!"; exit 0' } } stage('post') { steps { sh 'echo "post success!"; exit 0' } } stage('Test') { steps { sh 'echo "Failed!"; exit 1' } } } post { always { echo 'This will always run' } success { echo 'This will run only if successful' opsgenie(tags: "informational") } failure { echo 'This will run only if failed' opsgenie(tags: "failure, critical", teams: "engineering", priority:"P1") } unstable { echo 'This will run only if the run was marked as unstable' opsgenie() } changed { echo 'This will run only if the state of the Pipeline has changed' echo 'For example, if the Pipeline was previously failing but is now successful' } } }

Still need help?

The Atlassian Community is here for you.