Add to current sprint

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.

3 answers

This widget could not be displayed.

On JIRA Server or JIRA Cloud?

This widget could not be displayed.

Cloud

This widget could not be displayed.

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.

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

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 :(

Hmm, I'm afraid, Nunjucks is not supported by JMWE for JIRA Server...

That's true. But the same can be achieved using Groovy - we'll provide the script later today.

Thanks a lot! I’m looking forward. It’ll help me so much.

So, there is no way to get current sprint using groovy, I suppose...

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

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

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

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

Hi Max,

please refer to https://innovalog.atlassian.net/wiki/x/oIC8CQ for an updated version of this script.

Yes, this script will work with any 7.x version of Jira, but it requires JMWE version 5.1.0 or above.

Hi @David Fischer [Innovalog] 

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. 

No idea. Did you look at the Jira logs (atlassian-jira.log)? Did you try the post-function on a "normal" transition?

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. 

The link doesn’t work...

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..

Suggest an answer

Log in or Sign up to answer
Atlassian Summit 2018

Meet the community IRL

Atlassian Summit is an excellent opportunity for in-person support, training, and networking.

Learn more
Community showcase
Posted 10 hours ago in New to Jira

Are you planning to trial, or are currently trialling Jira Software? - We want to talk to you!

Hello! I'm Rayen, a product manager at Atlassian. My team and I are working hard to improve the trial experience for Jira Software Cloud. We are interested in   talking to 20 people planning t...

32 views 1 0
Join discussion

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you