Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
4,293,218
Community Members
 
Community Events
165
Community Groups

Statuspage http web request

Edited

Hello,

 

I am trying to use scriptrunner to sync JIRA and Statuspage using the API. I am able to get this to work within Automation for Jira using the Webhook action, but I needed to add logic in for multiple components. I took the exact header and body from the working Automation for Jira step but when I try to run it in groovy I can't get past compilation. 

Here is the code:



import groovyx.net.http.HTTPBuilder
import static groovyx.net.http.Method.POST
import static groovyx.net.http.ContentType.JSON

def incidentsURL = "https://api.statuspage.io/v1/pages/PAGEID/incidents/"
def http = new HTTPBuilder(incidentsURL)

return http.request(POST, JSON) { req ->
headers."Authorization" = "API_KEY"
body = [
{
"incident": {
"name": "{{issue.summary}}",
"status": "identified",
"metadata": {},
"deliver_notifications": true,
"body": "{{issue.description}}",
"components": {
"COMPONENTID_1": "degraded_performance",
"COMPONENTID_2": "degraded_performance"
},
"component_ids": [
"COMPONENTID_1",
"COMPONENTID_2"
]
}
}
]

response.success = { resp, json ->
assert resp.status == 200
log.debug("My response handler got response: ${resp.statusLine}")
if(htmlText){
return htmlText.getText()
}
else{
return null
}
}

// called only for a 404 (not found) status code:
response."404" = { resp ->
log.error ("Not found")
return null
}
}


I get this error:

Compilation error(s):
script_faebee5c347ccee6da33a12299bf286d.groovy: 18: expecting '}', found ':' @ line 18, column 13.
     "incident": {
               ^

 

2 answers

@Mike Abbe Has it been resolved?
I actually facing a similar issue now

I don't believe I ever got this working. I ended up licensing Opsgenie and building the integration between Jira and Statuspage through there. 

0 votes

@Mike Abbe -

Hi Mike:

In your code you have component_id mentioned twice -

     "components": {
"COMPONENTID_1": "degraded_performance",
"COMPONENTID_1": "degraded_performance"

Don't know if that was the cause of your error.

Best, Joseph Chung Yin

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
SERVER
TAGS
Community showcase
Posted in Jira Service Management

Jira Service Management Documentation Opportunities

Hello everyone, Hope everyone is safe! A few months ago we posted an article sharing all the new articles and documentation that we, the AMER Jira Service Management team created. As mentioned ...

145 views 0 3
Join discussion

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you