Groovy, store issue

Jeroen Baten March 6, 2014

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
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.
March 9, 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.

Jeroen Baten March 11, 2014

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
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.
March 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})"

0 votes
Jeroen Baten March 11, 2014

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
TAGS
AUG Leaders

Atlassian Community Events