Hello,
we having a scripted field which can calculate the total time spent on each issue. which showing up some errors but working fine. but, looks like throwing some errors. when we tried to re-index, script runner those errors are blocking the re-index process and even after 24hours re-indexing is 0%. when we re-index after disabling script runner, it was done in 4-5 hours.
we found the errors of script runner and trying to fix them but unfortunately, script runner folks cannot join the call to resolve the issue and they take 48 hours to just make a reply comment on we're having a hard time fixing this script from more than a month.
any help to fix this script would be appreciated.
import com.atlassian.core.util.DateUtils
def resolvedNames = ["Resolved", "Closed"]
def timeDiff;
if (issue.getStatus().name in resolvedNames) {
timeDiff = issue.getResolutionDate().getTime() - issue.getCreated().getTime()
} else {
timeDiff = System.currentTimeMillis() - issue.getCreated().getTime()
}
return timeDiff/(1000*60*60)
What are the errors you are getting?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
This is one of my big arguments against weakly typed languages - the laziness and guesswork leads us to silly errors like this (this is NOT the fault of the coder, it's the coding language failing the human). We gain ease of coding and prototyping, but lose way more time to worrying about conversions.
Here, groovy is guessing at a type. This is a bad thing to do, but groovy has a lot of other good things, so we still quite like it. If you make it explicit, and tell groovy to stop its painful guesswork, then it should work. Try casting the last line to what Jira is expecting:
return (double) timeDiff/(1000*60*60)
From memory, that should work, but if not, it should give us a better error message to work with.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Delete the field from production.
Test the scripted field in your staging/test Jira instance
Your script is vulnerable to admin error where closing or resolving an issue didn't set the Resolution field
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
If we delete, we will lose the data. since it is being used in hundreds of dashboards, we cannot delete. when I created the same field in staging with the same script, there are no errors.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Atlassian Government Cloud has achieved FedRAMP Authorization at the Moderate level! Join our webinar to learn how you can accelerate mission success and move work forward faster in cloud, all while ensuring your critical data is secure.
Register NowOnline 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.