Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Celebration

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root

Avatar

1 badge earned

Collect

Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!

Challenges
Coins

Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.

Recognition
Ribbon

Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!

Leaderboard

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,560,461
Community Members
 
Community Events
185
Community Groups

Jira cloud - Scriptrunner - Listener - Appending issue key

AbrahamA
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
Mar 27, 2023

Hello All

In the scriptrunner listener for issue created when I append $${issue.key} it is not working in put function, however if I hard code the key like XXX-152 it works

 

I am trying to update the issue.

What is the correct way to update issue in scriptrunner listener. Please let me know

 

This does not work

def issueKey = issue.key
def result = put('/rest/api/2/issue/${issue.key}') .header('Content-Type', 'application/json') .body([ fields:[ summary: newSummary ] ])

 

This works with hardcoded key


//def issueKey = 'DWS-152'
def issueKey = issue.key
logger.info("${issueKey} or ${issue.key}")
def newSummary = 'Updated by a script'


def result = put('/rest/api/2/issue/XXX-166')
.header('Content-Type', 'application/json')
.body([
fields:[
summary: newSummary
]
])
.asString()
if (result.status == 204) {
return 'Success'
} else {
return "${result.status}: ${result.body}"
}


 

Please let me know.

Abe

2 answers

0 votes
Jerryton Surya
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
Mar 27, 2023

Hi @AbrahamA 

Can you try this 

def issueKey = issue.key
def newSummary = 'Updated by a script'

def result = put("/rest/api/2/issue/${issueKey}")
.header('Content-Type', 'application/json')
.body([
fields:[
summary: newSummary
]
])
.asString()

if (result.status == 204) {
return 'Success'
} else {
return "${result.status}: ${result.body}"
}

0 votes
AbrahamA
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
Mar 27, 2023

If I use ${issueKey} as part of put URL here is what I get

2
2023-03-28 03:14:50.429 INFO - PUT /rest/api/2/issue/${issueKey} asString Request Duration: 14ms
2023-03-28 03:14:50.434 ERROR - java.net.URISyntaxException: Illegal character in path at index 110: https://us.argon.polaris.connect.product.adaptavist.com/proxy-service/rest/api/1/jira/proxy/rest/api/2/issue/${issueKey}
2023-03-28 03:14:50.448 ERROR - Class: com.adaptavist.sr.cloud.events.WebhookExecution, Config: null
Jerryton Surya
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
Mar 28, 2023

Okay @AbrahamA then the issue may be something else

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events