It's not the same without you
Join the community to find out what other Atlassian users are discussing, debating and creating.
Hey fellow JIRA users,
I know it's not the "agile" way, but here is what I want to do:
I want to dynamically remove an issue from the current sprint once it transitions to a certain status. Whether the issue is removed from the sprint is calculated based on some properties. Additionally, the issue type should be changed.
Calculating the properties and changing the issue type is not a problem. Removing it from the sprint however is.
The things I found online are suggesting to use the SprintHelper or SprintManagerImpl classes from the greenhopper-package. However, those classes are only taking a Collection or a List of issues are are throwing an exception when using an implementation of those interfaces e.g. ArrayList.
I'm aware that there is a build-in script in ScriptRunner, but how can I use this script inside a post function / custom script?
I saw that a similar question has been asked here https://community.atlassian.com/t5/Answers-Developer-Questions/ScriptRunner-Add-issue-to-sprint-or-c... but there has been no answer.
Thank you very much!
Came across this git https://gist.github.com/jechlin/9789183 and adapted the code a bit to fit my needs.
import com.atlassian.greenhopper.service.sprint.Sprint
import com.atlassian.greenhopper.service.sprint.SprintIssueService
import com.atlassian.jira.component.ComponentAccessor
import com.onresolve.scriptrunner.runner.customisers.ContextBaseScript
import com.onresolve.scriptrunner.runner.customisers.JiraAgileBean
import groovy.transform.BaseScript
@BaseScript ContextBaseScript baseScript
def issue = getIssueOrDefault("TP-1")
@JiraAgileBean
SprintIssueService sprintIssueService
def currentUser = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser()
def sprintsForIssue = sprintIssueService.getSprintsForIssue(loggedInUser, issue)
Sprint activeSprint = sprintsForIssue.getValue().find{it.active}
if (activeSprint) {
log.info "Adding issue $issue to ${activeSprint.name} with sprint id ${activeSprint.id}"
sprintIssueService.removeIssuesFromSprint(currentUser, activeSprint, [issue] as Collection)
}
else {
log.info ("could not find active sprints for isse ${issue.key}")
}
Are there any other suggestions? :)
Have you tried to use REST for this purpose? https://confluence.atlassian.com/jirakb/how-to-add-and-remove-issue-to-from-sprint-via-rest-api-779158574.html
This community is celebrating its one-year anniversary and Atlassian co-founder Mike Cannon-Brookes has all the feels.
Read moreHey Atlassian Community! Today we are launching a bunch of customer stories about the amazing work teams, like Dropbox and Twilio, are doing with Jira. You can check out the stories here. The thi...
Connect with like-minded Atlassian users at free events near you!
Find a groupConnect with like-minded Atlassian users at free events near you!
Unfortunately there are no AUG chapters near you at the moment.
Start an AUGYou're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.