I am trying to move all the issues with Done status to Close status when a sprint is closed.
I have custom listener to perform the operation but the script didn't work.
I am not sure what's wrong with the script.
Any help on this would be greatly appreciated.
Thanks!
For those who are looking to perform the same using Script Runner, here is the code that worked for me:
Hi @Stuti Golwala can you help please?
I changed your code a little bit to transition an issue when the sprint its started.
The logs shows this error.
And this is my code.
Thank you,
Fabio
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.
The error it's the same.
2020-02-05 11:24:05,918 ERROR [runner.AbstractScriptListener]: ************************************************************************************* 2020-02-05 11:24:05,918 ERROR [runner.AbstractScriptListener]: Script function failed on event: com.atlassian.greenhopper.api.events.sprint.SprintStartedEvent, file: null groovy.lang.MissingPropertyException: No such property: actionId for class: Script1419 at Script1419$_run_closure1.doCall(Script1419.groovy:30) at Script1419.run(Script1419.groovy:27)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Worked!!!
I changed the actionID to actionId and not the issueId.
Thank you for your help
Fabio
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
Providing the logs would help debugging. Anyway I use a different approach that has been working fine, which would be (using your parameters) :
import com.atlassian.jira.workflow.WorkflowTransitionUtil
import com.atlassian.jira.workflow.WorkflowTransitionUtilImpl
import com.atlassian.jira.util.JiraUtils
WorkflowTransitionUtil workflowTransitionUtil = ( WorkflowTransitionUtil ) JiraUtils.loadComponent( WorkflowTransitionUtilImpl.class );
workflowTransitionUtil.setIssue(issue);
workflowTransitionUtil.setUserkey(currentUser.getKey())
workflowTransitionUtil.setAction(actionId);
workflowTransitionUtil.progress();
Antoine
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Antoine,
Thank you for your reply.
From your code, will it move all issues or a particular issue to close status? Also, do I have to mention the issue id in the code? If yes, then I am afraid to use it as I don't want the issue to be static.
I am sorry if I have not understood your code. This is my first groovy script.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
You are welcome to ask any question !
If you are using a Script Listener, the script is triggering on the event(s) you are mapping to it.
Events are triggered in workflow (Issue created/Issue closed...) transitions. You can change which event is triggered in a transition, and you can create custom events.
There are also system events (Issue Assigned/Issue updated/Issue commented...). In previous cases you can use "issue" as your object, i.e. the issue on which the event is triggered - Sorry if you knew all this already.
So in your case I guess you are using the SprintClosedEvent event. I have never used it, but you can find an exemple here : https://scriptrunner.adaptavist.com/latest/jira/listeners.html#_jira_software_events
In this case your are gonna need to use the "event" object, to retrieve the sprint which has been closed. Once you have retrieved the issues that you want to update, you can use my script for each of them.
As this not very well documented, I would advise to use logs a lot to check objects values and their class (using .getClass()) to check the documentation, such as the sprint.
Good luck, very interested in the outcome. :)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Antoine,
Thank you for the detailed explanation. I will try to script and see what is comes out to.
I will surely post the solution here whenever I have it.
Thanks again!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hey Antoine,
Forgot to attach the logs of my code that I have attached in my first post.
The following log information was produced by this execution. Use statements like:log.info("...") to record logging information.
2019-04-05 19:04:31,708 ERROR [runner.AbstractScriptListener]: ************************************************************************************* 2019-04-05 19:04:31,710 ERROR [runner.AbstractScriptListener]: Script function failed on event: com.atlassian.greenhopper.api.events.sprint.SprintClosedEvent, file: <inline script> org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed: Script89.groovy: 29: unable to resolve class IssueInputParametersImpl @ line 29, column 95. rrentUser, issue.id, actionId,new IssueI ^ 1 error
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You are missing the class, use this import
import com.atlassian.jira.issue.IssueInputParametersImpl
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thank you Antoine for the catch.
I have added it but still getting an error.
Code:
Error:
Time (on server): Mon Apr 08 2019 09:19:07 GMT-0700 (Pacific Daylight Time)
The following log information was produced by this execution. Use statements like:log.info("...") to record logging information.
2019-04-08 16:19:07,924 ERROR [runner.AbstractScriptListener]: ************************************************************************************* 2019-04-08 16:19:07,924 ERROR [runner.AbstractScriptListener]: Script function failed on event: com.atlassian.greenhopper.api.events.sprint.SprintClosedEvent, file: <inline script> groovy.lang.MissingPropertyException: No such property: issue for class: com.atlassian.greenhopper.api.events.sprint.SprintClosedEvent at Script117.run(Script117.groovy:21)
I have added the library "com.atlassian.greenhopper.api.events.sprint.SprintClosedEvent" but still failing the execution.
Not sure what to add/remove.
Thanks!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
The problem seems to be that your "issue" object is null. I would advise to log the objects you are creating so you can see what is working and what is not. Example after line 15 :
log.error("issue : " + issue)
In this particular case since you are triggering a Sprint Closed event, the listener is bound to the Sprint object and not the issue, that is why your issue is null (That is what I would assume since I have not tried using this particular event).
i.e.
event.issue
returns null. That is my guess. You need to retrieve the issues from the sprint object (event.sprint) as in the example provided by scriptrunner.
Antoine
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.
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.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.