You're on your way to the next level! Join the Kudos program to earn points and save your progress.
Level 1: Seed
25 / 150 points
Next: Root
1 badge earned
Challenges come and go, but your rewards stay with you. Do more to earn more!
What goes around comes around! Share the love by gifting kudos to your peers.
Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!
Join now to unlock these features and more
Hi all,
I have two instances of Jira Server and need integrate them. I've made a groovy script and add it to post function on issue creation step. This script sends rest requests to another Jira to make issue there. But sometimes another Jira has performance issues and answers with 502 error. Problems can last for several minutes (sometimes more). How can I handle this case? Is it a good idea to add a loop to send a request until I get a 200 response? I'm afraid that in this case issue won't be created in first Jira instance for a long time if another instance having problems for a long time
Or may be I can make not a post function script but Listener which listens issue created event and add a loop to send a request until I get a 200 response there?
Hi @Ram Kumar Aravindakshan _Adaptavist_
It's a custom post-function on transition. Script just create new issue in another instance of Jira if some conditions true
I need to add code only in one instance
And on issue transition fires my script which send request from instance 1 to instance 2 and if in this time instance 2 slows down issue in instance 2 not created. Is it good idea to loop sending request in instance 1 while instance 2 not stops slowing down
String jkIssueKey = createIssueInJiraJK()
if (jkIssueKey != null){
commentIssues(jkIssueKey)
} else{
log.warn("Issue not created, comment not added")
}
log.info("End of script")
def createIssueInJiraJK(){
def jkIssueKey = null
def currentIssue = issue.key
def createdIssueKey
def addressJira = "https://jira.anotherinstance.net"
def user = ''
def password = ''
def authString = "${user}:${password}".bytes.encodeBase64().toString()
def timeout = 120000
def defaultRequestConfig = RequestConfig.custom()
.setConnectionRequestTimeout(timeout)
.setConnectTimeout(timeout)
.setSocketTimeout(timeout)
.build()
def http = new HTTPBuilder("${addressJira}/rest/api/2/issue")
http.ignoreSSLIssues();
http.setClient(HttpClients.custom().setDefaultRequestConfig(defaultRequestConfig).build())
try {
http.request(POST, ContentType.JSON) {
headers.'Authorization' = "Basic ${authString}"
body = ["fields":[
"project":[
"id":"100"
],
"summary":"${value_currentSummary}.toString(),
"issuetype":[
"id":"11"
],
"priority": [
"id": "2"
],
"description":"Description".toString()
]
]
requestContentType = ContentType.JSON
response.success = { resp, json ->
jkIssueKey = json.key
log.info("Issue ${jkIssueKey} was created")
return jkIssueKey
}
response.failure = { resp ->
log.warn("response code is: " + resp.status.toString())
}
}
} catch (Exception e) {
log.warn("Exception : " + e)
}
}
Hi @aas
In your description, you mentioned:-
I have two instances of Jira Server and need integrate them. I've made a groovy script and add it to post function on issue creation step.
Are you adding the code in both instances with the required modifications?
Please share your Post-Function code so I can review it and suggest a better solution.
Also, please clarify what Post-Function you use to make the REST request. Is it the ScriptRunner Custom post-function?
I am looking forward to your feedback.
Thank you and Kind regards,
Ram
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @Ram Kumar Aravindakshan _Adaptavist_
I accidentally answered in the wrong place. Look my answer above please
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.