Groovy, store issue

Hi,

So I made a groovy script to compare and fix the fixVersions field in subtasks based on the content of the parent issue. My big question now is: how do I store this issue back into Jira? I am using Jira 6.0.8.

Any and all help is highly appreciated.

Kind regards,

Jeroen Baten

2 answers

1 vote
Henning Tietgens Community Champion Mar 09, 2014

The prefered way of changing an issue is descibed on the page Performing Issue Operations. If you use this way you don't have to worry about business logic (permissions) and indexing. You don't have to modify an issue object, it's all done by definining the new value within the IssueInputParameters.

A simpler way is to use the IsssueManager and its updateIssue() method after you modified the issue object. This method should take care of the indexing also, but doesn't check for appropiate permissions.

If you try to change an issue within a scripted postfunction or a listener there are some other things you have to take care of, but your questions doesn't suggest anything like that.

If I use IssueService.IssueResult issueResult = issueService.getIssue(currentUserObj,Issue) he complains about me not having enough rights. If I use as currentUserObj the value "null" he does too. What am I doing wrong?

Henning Tietgens Community Champion Mar 12, 2014

Is currentUserObj a valid user? And what's "Issue"? It has to be an issue key (String) or an issue ID (long). Try to log both variables and their classes before calling the method.

log.setLevel(org.apache.log4j.Level.DEBUG)
log.debug "$currentUserObj (${currentUserObj?.class.name})"
log.debug "$Issue (${Issue?.class.name})"

If I use IssueService.IssueResult issueResult = issueService.getIssue(currentUserObj,Issue) he complains about me not having enough rights. If I use as currentUserObj the value "null" he does too. What am I doing wrong?

Suggest an answer

Log in or Sign up to answer
Community showcase
Published Oct 31, 2018 in Marketplace Apps

Marketplace Spotlight: Zephyr

Hello Atlassian Community! Each month, we run a series of Spotlights to highlight Marketplace vendors and apps that our team thinks this Community would find valuable. In last month's Spotlig...

335 views 0 1
Read article

Atlassian User Groups

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

Find a group

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

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you