Is there any way to add an issue to the current sprint on transition? I want to auto add issues to the active sprint when devs (who forget to move their issue) transition it to in progress.
This feature is not currently available in JMWE for JIRA Cloud, but I've created https://innovalog.atlassian.net/browse/MWEC-126 which you might want to vote for and watch. We might be able to release this feature later this month.
However, note that sprints belong to Boards, so you will have to specify a board ID (there is no way currently to identify which board(s) an issue belongs to).
So, how to add an issue to the current sprint? I can see that the suggestion is implemented. But I can't find this functionality in JMWE.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
The aforementioned ticket contains a code snippet that returns the current sprint ID. You can use the Set Field Value post function to set the Sprint field to that value. See https://innovalog.atlassian.net/wiki/spaces/JMWEC/pages/138405679/Custom+Nunjucks+filters#CustomNunjucksfilters-sprints and https://innovalog.atlassian.net/wiki/spaces/JMWEC/pages/94142534/Set+field+value
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I tried it. A create such a Post Function for `Done`:
```
The value of field Sprint of the current issue will be set to the following Groovy Template: {{ issue | sprints("active") | first | field("id") }} (replacing existing values).
```
It doesn't do anything though. I don't understand what's wrong :(
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hmm, I'm afraid, Nunjucks is not supported by JMWE for JIRA Server...
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
That's true. But the same can be achieved using Groovy - we'll provide the script later today.
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.
So, there is no way to get current sprint using groovy, I suppose...
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Actually, there is, but Jira Software doesn't make it easy.
The following script should work to return the Sprint ID (number), but you'll have to customize it with the numerical ID of the Scrum board (because there is no direct relationship between issues and Scrum boards - an issue can even belong to multiple boards). That number is the "rapidView=" parameter of your board's URL.
import com.atlassian.jira.component.ComponentAccessor
def boardId = 2
def classLoader = issue.get("Rank").getClass().getClassLoader()
def RapidViewServiceIntf = classLoader.findClass("com.atlassian.greenhopper.service.rapid.view.RapidViewService")
def RapidViewService = ComponentAccessor.getOSGiComponentInstanceOfType(RapidViewServiceIntf)
def board = RapidViewService.getRapidView(currentUser, boardId).get()
def SprintServiceIntf = classLoader.findClass("com.atlassian.greenhopper.service.sprint.SprintService")
def SprintService = ComponentAccessor.getOSGiComponentInstanceOfType(SprintServiceIntf)
def PageRequests = classLoader.findClass("com.atlassian.greenhopper.service.PageRequests")
def SprintQuery = classLoader.findClass("com.atlassian.greenhopper.service.sprint.SprintQuery")
def State = classLoader.findClass("com.atlassian.greenhopper.service.sprint.Sprint").getClasses()[1]
def sprintQuery = SprintQuery.builder().states(Collections.singleton(State.ACTIVE)).build()
def sprintsOutcome = SprintService.getSprints(currentUser, board, PageRequests.all(), sprintQuery)
if (sprintsOutcome.isInvalid())
throw new UnsupportedOperationException(sprintsOutcome.toString())
def sprints = sprintsOutcome.get().getValues()
if (sprints.size() > 1)
throw new UnsupportedOperationException("More than one sprint is active")
return sprints[0].getId()
We'll try to make it easier in a future version of JMWE for Jira Server.
David
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi David!
I've tried to use this script as a postfunction. My aim is to fill current active sprint by default for new tasks. I've choosen "Create issue" on workdlow diagram, added new postfunction. I use "Set filed value (JMWE)" option. As an affected field I've set "Sprint", as value type - Groovy Expression.
When I try to test you script, I have an error:
java.lang.IllegalArgumentException: Unable to find field 'Rank'
And this postfunction does not allow to create new tasks at all.
So, can I do something to resolve this?
P.S: Jira Server 7.8.0, JMWE 5.2.0
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi David!
I've tried to use this script as a postfunction. My aim is to fill current active sprint by default for new tasks. I've choosen "Create issue" on workdlow diagram, added new postfunction. I use "Set filed value (JMWE)" option. As an affected field I've set "Sprint", as value type - Groovy Expression.
When I try to test your script, I have an error:
java.lang.IllegalArgumentException: Unable to find field 'Rank'
And this postfunction does not allow to create new tasks at all.
So, can I do something to resolve this?
P.S: Jira Server 7.8.0, JMWE 5.2.0
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi David!
I've tried to use this script as a postfunction. My aim is to fill current active sprint by default for new tasks. I've choosen "Create issue" on workdlow diagram, added new postfunction. I use "Set filed value (JMWE)" option. As an affected field I've set "Sprint", as value type - Groovy Expression.
When I try to test this script, I have an error:
java.lang.IllegalArgumentException: Unable to find field 'Rank'
And this postfunction does not allow to create new tasks at all.
So, can I do something to resolve this?
P.S: Jira Server 7.8.0, JMWE 5.2.0
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Max,
please refer to https://innovalog.atlassian.net/wiki/x/oIC8CQ for an updated version of this script.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thank you! Works excelent for me!
Can this script also run in Jira Server 7.6.2?
P.S: wiki link for me was https://innovalog.atlassian.net/wiki/spaces/JMWE/pages/68878646/Use+cases+for+post+functions#Usecasesforpostfunctions-AddtheissuetothecurrentactiveSprint
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Yes, this script will work with any 7.x version of Jira, but it requires JMWE version 5.1.0 or above.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You're first script seems to work for me when I try it using the "Test Groovy Script" button. However after I've added this to the post-function of the workflow transition (on creation of the issue) the Sprint value never gets filled in. Any ideas why this could be?
We're on Jira 7.6.3 and JMWE version 5.0.6.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
No idea. Did you look at the Jira logs (atlassian-jira.log)? Did you try the post-function on a "normal" transition?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thanks for your quick reply. I was going through some documentation of JMWE and found another troubleshooting article on a create transition and figured out the solution was to put the post-function after all the other (default) post-functions.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi David,
I have another issue. Can you please help me with it ?
Thanks in deed..
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.
Hi David,
It's strange. I cannot add the correct link. Can you please find the topic under my profile ?
How can I set value 0 if a transitioon count field is empty ?
Thanks..
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.
On JIRA Server or JIRA Cloud?
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.