Opsgenie does not notify slack if there are problems with a Jenkins pipeline
Asked by Jo?o Freire:

Greetings, I'm integrating Opsgenie with Jenkins from pipelines. I created 2 pipelines with the same code that represents a sample code present in this link: <https://support.atlassian.com/opsgenie/docs/integrate-opsgenie-with-jenkins/>.

In the first case use the groovy sandbox to run the pipeline script and in the second case I ran the script from a Jenkinsfile.

Case 1: {#toc-hId--1215137845}
------------------------------

Jenkins Pipeline:

![Screenshot at Sep 20 15-01-28.png](/t5/image/serverpage/image-id/161090i64859E642B0B470F/image-size/large?v=v2&px=999 "Screenshot at Sep 20 15-01-28.png")

Jenkins Pipeline Job:

![Screenshot at Sep 20 15-03-32.png](/t5/image/serverpage/image-id/161091i6C2A7C7752514B1A/image-size/large?v=v2&px=999 "Screenshot at Sep 20 15-03-32.png")

Opsgenie notification (via slack):

![Screenshot at Sep 20 15-13-55.png](/t5/image/serverpage/image-id/161092i5A4A35E82926A902/image-size/large?v=v2&px=999 "Screenshot at Sep 20 15-13-55.png")

In this case, everything went as it should. I ran the pipeline and gave an error to verify that the failure notification appeared in Opsgenie and is validated.

Case2: {#toc-hId-1272374988}
----------------------------

Jenkinsfile:

![Screenshot at Sep 20 15-27-55.png](/t5/image/serverpage/image-id/161097i763E2C44B8099B04/image-size/large?v=v2&px=999 "Screenshot at Sep 20 15-27-55.png")

Jenkins Pipeline:

![Screenshot at Sep 20 15-28-45.png](/t5/image/serverpage/image-id/161098i9314C3D522A47005/image-size/large?v=v2&px=999 "Screenshot at Sep 20 15-28-45.png")

Jenkins Pipeline Job:

![Screenshot at Sep 20 15-29-51.png](/t5/image/serverpage/image-id/161099iA15CB68FAC632332/image-size/large?v=v2&px=999 "Screenshot at Sep 20 15-29-51.png")  
As you can see in the Jenkins pipeline job screenshot, the request for Opsgenie is made. My question or problem is that Opsgenie does not notify slack as it did in the first case, so I would like to have some help here if possible.   
cheers.


Answers:
author: Justin Sitarz
body: Hi Jo?o!

Justin here, from Opsgenie support - happy to help!

There are a few common culprits that can prevent a particular alert from sending out to Slack - it may be that the alert that is created is not assigned to the same team as the Slack integration, or it may be that the Slack integration has some filtering in place that is preventing alerts matching certain criteria from sending outbound.

For the first - can you check to see that both of these alerts in Opsgenie are assigned to the same team as your Slack integration? You can find the assigned responder teams here on the alert:

![alert.png](https://community.atlassian.com/t5/image/serverpage/image-id/161372iD35C419F5F608F2B/image-size/large?v=v2&px=999 "alert.png")

You'll want to ensure that this is the same as your Slack integration:

![integration-team.png](https://community.atlassian.com/t5/image/serverpage/image-id/161373i3C16431F7BEA5A45/image-size/large?v=v2&px=999 "integration-team.png")

Additionally, you'll want to check if there are any filters here, on the Slack integration, that might be preventing the alert from sending out to Slack:

![alert-filter.png](https://community.atlassian.com/t5/image/serverpage/image-id/161374i2845CC7A3596E137/image-size/large?v=v2&px=999 "alert-filter.png")

Those are the most common causes of something like this, but if that doesn't solve the issue, please feel free to respond here, or reach out to us directly at support.atlassian.com.

Thanks!

Justin S.

Atlassian Cloud Support

comments: author: Jo?o Freire
body: Good morning, thanks for the reply. I think I exposed the error incorrectly. The problem isn't in the slack because the alert doesn't reach Opsgenie. What I exposed already worked correctly with the same code by a pipeline script or a pipeline script by scm.

That said, my company only uses scripted pipelines. The code shown above refers to the example of this link : <https://support.atlassian.com/opsgenie/docs/integrate-opsgenie-with-jenkins/> .This code is declarative and works correctly, the alert is sent to Opsgenie and later to slack.

But as mentioned above, we only use scripted pipelines and what happens is that when I call the Opsgenie function in this type of pipeline, the output says that the alert is sent but it doesn't reach Opsgenie.

Scripted Pipeline Code:

![Screenshot at Sep 22 12-51-49.png](https://community.atlassian.com/t5/image/serverpage/image-id/161527i89066DF04F701002/image-size/large?v=v2&px=999 "Screenshot at Sep 22 12-51-49.png")

Output of Scripted Pipeline:

![Screenshot at Sep 22 12-53-37.png](https://community.atlassian.com/t5/image/serverpage/image-id/161530i31B33E68EC43CD1E/image-size/large?v=v2&px=999 "Screenshot at Sep 22 12-53-37.png")

<br />

Supposedly job data is sent to Opsgenie but the alert does not appear in Opsgenie when the command is called within a scripted pipeline.

Is something missing in my code or does Opsgenie only allow in-command invocation in declarative pipelines?

Cheers.


author: Justin Sitarz
body: Hi Jo?o,

Ah, thanks for the additional information! With that in mind, I \*suspect\* that the issue has to do with your Opsgenie configuration - it may be that the data is received by Opsgenie, but doesn't match the filter conditions for the rules in the 'Create Alert' action for your integration - see below for a screenshot of where this is found:

![Screen Shot 2021-09-22 at 8.43.23 AM.png](https://community.atlassian.com/t5/image/serverpage/image-id/161565i28154D01B38BD4D3/image-size/large?v=v2&px=999 "Screen Shot 2021-09-22 at 8.43.23 AM.png")

The best way to check this is to view the logs (Settings \>\> Logs), where all incoming requests will be displayed, whether they trigger an alert to be created or not. You can search the logs using the name or ID of the Jenkins integration, and will see all request received by that integration, and can confirm if the specific notification from your scripted pipeline.

You may also want to reach out to us directly at support.atlassian.com, or through the in-app chat (found in the lower right hand corner of the application - note -i f you don't see the in-app chat option, it may be due to an ad-blocker extension in your browser.)

We may need to gain access to your account to do some additional troubleshooting of the issue, so contacting us directly would be the best way to achieve that.

Thanks!

Justin S.

Atlassian Cloud Support


author: Jo?o Freire
body: Good morning Justin, thanks for your help. I didn't know where I could see the logs and what was happening was that the status always showed up as "Success". So I added this line in my code and it's working correctly.

![Screenshot at Sep 23 11-37-58.png](https://community.atlassian.com/t5/image/serverpage/image-id/161730i56FC49AFF939EC8D/image-size/large?v=v2&px=999 "Screenshot at Sep 23 11-37-58.png")

Thanks again for your availability.

Cheers.


author: Justin Sitarz
body: Hi Jo?o,

Excellent, glad it's working now! Is there anything else we can help with?

Best,

Justin S.

Atlassian Cloud Support


author: Jo?o Freire
body: I don't think I have any problems for now, thank you so much for your attention.

Cheers.


Tags: cloud