Hi all, I need to count whenever issues pass through a particular status (test failed for example).
I've looked at this solution (https://community.atlassian.com/t5/Jira-questions/Need-a-custom-field-that-updates-the-value-with-an-1-increment/qaq-p/901418) but the problem with this is it keeps the number across all issues, not per issue.
Any one can help me with this (as clearly I'm not that good at groovy scripting)?
Yes I do have scriprunner plugin installed.
If you have the JMWE (Jira Misc. Workflow Extension) it's pretty easy. On the transition flow that goes into the status you want to track, add a post function and use the "Increase value of field" option. This assumes you have created a field to use.
We use this approach to track how many times an issue goes into the "Reopen" status.
Unfortunately we do not use that addon, as we opted for JSU (which is quite similar).
For anyone wondering, managed to do this through scriprunner. Upon further research found a similar question, and had to modify a bit the code to work for me. Below is the code if anyone is interested:
import com.atlassian.jira.issue.CustomFieldManager
import com.atlassian.jira.issue.fields.CustomField
import com.atlassian.jira.issue.util.DefaultIssueChangeHolder
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.ModifiedValue;
DefaultIssueChangeHolder changeHolder = new DefaultIssueChangeHolder();
CustomFieldManager customFieldManager = ComponentAccessor.getCustomFieldManager();
CustomField cf = customFieldManager.getCustomFieldObjectByName("Your Custom Field");
Double currValue = (Double)cf.getValue(issue);
if (currValue == null) {
currValue = 0;
}
Double newValue = currValue+1;
cf.updateValue(null, issue, new ModifiedValue(currValue,newValue), changeHolder);
P.S. for this to work, the Your Custom Field needs to be type number, not text :)
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.