I am using scriptrunner and I was trying to use the Script Listener to trigger on the issue close event to set remaining estimate to zero. When I create this and enter the script through the inline entry it does not work. When I create on the server (exact same script) and call the script file instead it works.
I would prefer to have my developers work through the inline script method instead of given server access.
What is the difference between this two methods?
Thank you!
In this context, there should be no difference. "Not works" - how? Checked the logs?
The Inline script option when showing successful executions, states it was successful. However remaining estimate is not set to 0. I have no error messages in the log files.
Note the following script will produce compile errors. I have an inline version that does not produce errors, but that did not solve any problems.
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.event.issue.AbstractIssueEventListener
import com.atlassian.jira.event.issue.IssueEvent
import com.atlassian.jira.issue.MutableIssue
import com.atlassian.jira.issue.index.IssueIndexManager
import com.atlassian.jira.util.ImportUtils
class RemainingEstimateZero extends AbstractIssueEventListener {
@Override
void workflowEvent(IssueEvent event) {
def componentAccessor = new ComponentAccessor()
IssueIndexManager indexManager = ComponentAccessor.getComponent(IssueIndexManager.class)
def MutableIssue issue = event.getIssue()
//used to reindex the issue at the bottom
boolean wasIndexing = ImportUtils.isIndexIssues();
ImportUtils.setIndexIssues(true);
if (issue.estimate == null || issue.estimate > 0)
issue.setEstimate(0)
//reindex issue
indexManager.reIndex(issue);
ImportUtils.setIndexIssues(wasIndexing);
}
}
Taking this same script and placing it in the jira/scripts folder and pointing the listener to (with same compile errors) works successfully. On transition to close the remaining estimate is set to 0.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
oh ok - for event listeners IIRC you need to structure that as a script to use it inline, not a class.
So, you should end up with (after cleanup):
import com.atlassian.jira.component.ComponentAccessor import com.atlassian.jira.issue.MutableIssue import com.atlassian.jira.issue.index.IssueIndexManager import com.atlassian.jira.util.ImportUtils IssueIndexManager indexManager = ComponentAccessor.getComponent(IssueIndexManager.class) def MutableIssue issue = event.getIssue() //used to reindex the issue at the bottom boolean wasIndexing = ImportUtils.isIndexIssues(); ImportUtils.setIndexIssues(true); if (issue.estimate == null || issue.estimate > 0) issue.setEstimate(0) //reindex issue indexManager.reIndex(issue); ImportUtils.setIndexIssues(wasIndexing);
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.