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
Atlassian Community Anniversary

Happy Anniversary, Atlassian Community!

This community is celebrating its one-year anniversary and Atlassian co-founder Mike Cannon-Brookes has all the feels.

Read more
Community showcase
Published Apr 19, 2018 in Marketplace Apps

Calling all developers––You're invited to Atlas Camp 2018

 Atlas Camp   is our developer event which will take place in Barcelona, Spain  from the 6th -7th of   September . This is a great opportunity to meet other developers and get n...

366 views 0 6
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