For a given set of issues, I am trying to get the active sprint for each issue and determine if they are all the same sprint. How can I achieve this using a groovy script?
I'm probably just missing something in the javadoc, but I can't find anything that will allow me to get an issue's active sprint(s). What is the return type of the Sprint custom field type? I found this answer to be helpful to me, but it only pulls the data for the last sprint, not the current active one (if it exists).
This regards JIRA Softare 7.3.1, by the way.
I figured out a way to do this based on the previous answer I already found. This script also doesn't take into account parallel sprints because we don't have that enabled in our instance.
import com.atlassian.jira.component.ComponentAccessor def sprintField = ComponentAccessor.getCustomFieldManager().getCustomFieldObjectByName("Sprint") def sprintName def allSameSprint = false // initialize to "false" in case none of the issues belong to any sprint for (issue in issues) { def sprint = issue.getCustomFieldValue(sprintField) def sprintState = sprint?.state?.last()?.toString() if (sprintState.equals("ACTIVE")) { // set to "true" sprintName isn't filled yet if (sprintName == null) { this.sprintName = sprint?.name?.last()?.toString() allSameSprint = true } // set back to "false" if another sprint name is found else if (!sprintName.equals(sprint?.name?.last()?.toString())) { allSameSprint = false } } // if an inactive sprint is found, set to "false" else { allSameSprint = false } }
I'm not the most graceful coder, so if someone knows of a better, more elegant way to do the same thing, please let me know. :)
Hi,
I can't find the "state" property anywhere in the documentation. Tried:
I'm trying not to depend on implementation details, but rather on documented API features.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
same problem. I would believe that the sprint field returns some sort of collection of sprints, and not the sprint itself, but still the line defining sprintState doesn't make sense to me, and won't compile in the groovy script runner as written
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
For me, works.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Using Jira Misc Workflow Extension Add-on:
issue.get("Sprint")*.state?.toString().flatten()
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.