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

On JIRA Server or JIRA Cloud?

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

Suggest an answer

Log in or Join to answer
Community showcase
Teodora [Botron]
Published Feb 15, 2018 in Marketplace Apps

Jira Inferno: The Nine Circles of Jira Administration Hell

If you spend enough time as a Jira admin - whether you are managing a single, mid-sized instance, a large enterprise one or juggling multiple instances at once - you will eventually find yourself in ...

1,223 views 6 19
Read article

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
Atlassian Team Tour

Join us on the Team Tour

We're bringing product updates and pro tips on teamwork to ten cities around the world.

Save your spot