You're on your way to the next level! Join the Kudos program to earn points and save your progress.
Level 1: Seed
25 / 150 points
Next: Root
1 badge earned
Challenges come and go, but your rewards stay with you. Do more to earn more!
What goes around comes around! Share the love by gifting kudos to your peers.
Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!
Join now to unlock these features and more
The Atlassian Community can help you and your team get more value out of Atlassian products and practices.
I want to create new sprint on board with groovy script.
create code is:
Sprint.SprintBuilder builder = Sprint.builder();
builder.name("new-Sprint");
builder.startDate(1);
builder.endDate(1);
builder.completeDate(1);
Sprint newSprint = builder.build();
sprintManager.createSprint(newSprint);
when I list all sprints with groovy code, I can see created sprint bu not seen on any board in jira.
how to achive this?
You also need to specify the board with:
builder.rapidViewId(boardId);
The board-ID is included in the board's URL after the parameter rapidView.
@Ivo_de_Vries This is part of my code:
def newSprintId = this.createSprint(viewId, "${sprintKey}-${currentSprintID+1}", Sprint.State.FUTURE)
Sprint newSprint = sprintManager.getSprint(newSprintId as Long).getValue()
log.warn "Starting new sprint ${newSprint.name} with incomplete issues"
sprintIssueService.moveIssuesToSprint(user, newSprint, issues)
this.updateSprintState(suitableSprint, Sprint.State.CLOSED, null, null)
this.updateSprintState(newSprint, Sprint.State.ACTIVE, new DateTime().now(), new DateTime().now().plusWeeks(sprintTimes))
and methods for creating and updating sprints:
def createSprint(Long rapidViewId, String sprintName, Sprint.State state) {
def sprintManager = PluginModuleCompilationCustomiser.getGreenHopperBean(SprintManager)
Sprint.SprintBuilder builder = Sprint.builder().rapidViewId(rapidViewId).name(sprintName).state(state)
def newSprint = builder.build()
def outcome = sprintManager.createSprint(newSprint)
if (outcome.isInvalid()) {
log.error "Could not update sprint with name ${newSprint.name}, ${outcome.getErrors()}"
} else {
log.warn "${newSprint.name} has been created."
return outcome.get().id
}
}
def updateSprintState(Sprint sprint, Sprint.State state, org.joda.time.DateTime startDate, org.joda.time.DateTime endDate) {
def sprintManager = PluginModuleCompilationCustomiser.getGreenHopperBean(SprintManager)
if(startDate && endDate && state == state.ACTIVE){
def currentSprint = sprint.builder(sprint).state(state).startDate(startDate).endDate(endDate).build()
def outcome = sprintManager.updateSprint(currentSprint)
if (outcome.isInvalid()) {
log.error "Could not update sprint with name ${sprint.name}, ${outcome.getErrors()}"
} else {
log.warn "${sprint.name} has been activated."
}
}
else if(!startDate && !endDate && state == state.CLOSED){
def currentSprint = sprint.builder(sprint).state(state).build()
def outcome = sprintManager.updateSprint(currentSprint)
if (outcome.isInvalid()) {
log.error "Could not update sprint with name ${sprint.name}, ${outcome.getErrors()}"
} else {
log.warn "${sprint.name} has been closed."
}
}
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
@metinbulak were you able to solve this problem? I am able to close the current active sprints but now I want to automatically create a new sprint (as an increment of the previous one), move all tickets from the previous sprint to the newly created one and start it.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
This is part of my code:
def newSprintId = this.createSprint(viewId, "${sprintKey}-${currentSprintID+1}", Sprint.State.FUTURE)
Sprint newSprint = sprintManager.getSprint(newSprintId as Long).getValue()
log.warn "Starting new sprint ${newSprint.name} with incomplete issues"
sprintIssueService.moveIssuesToSprint(user, newSprint, issues)
this.updateSprintState(suitableSprint, Sprint.State.CLOSED, null, null)
this.updateSprintState(newSprint, Sprint.State.ACTIVE, new DateTime().now(), new DateTime().now().plusWeeks(sprintTimes))
and metods for creating and updating sprints:
def createSprint(Long rapidViewId, String sprintName, Sprint.State state) {
def sprintManager = PluginModuleCompilationCustomiser.getGreenHopperBean(SprintManager)
Sprint.SprintBuilder builder = Sprint.builder().rapidViewId(rapidViewId).name(sprintName).state(state)
def newSprint = builder.build()
def outcome = sprintManager.createSprint(newSprint)
if (outcome.isInvalid()) {
log.error "Could not update sprint with name ${newSprint.name}, ${outcome.getErrors()}"
} else {
log.warn "${newSprint.name} has been created."
return outcome.get().id
}
}
def updateSprintState(Sprint sprint, Sprint.State state, org.joda.time.DateTime startDate, org.joda.time.DateTime endDate) {
def sprintManager = PluginModuleCompilationCustomiser.getGreenHopperBean(SprintManager)
if(startDate && endDate && state == state.ACTIVE){
def currentSprint = sprint.builder(sprint).state(state).startDate(startDate).endDate(endDate).build()
def outcome = sprintManager.updateSprint(currentSprint)
if (outcome.isInvalid()) {
log.error "Could not update sprint with name ${sprint.name}, ${outcome.getErrors()}"
} else {
log.warn "${sprint.name} has been activated."
}
}
else if(!startDate && !endDate && state == state.CLOSED){
def currentSprint = sprint.builder(sprint).state(state).build()
def outcome = sprintManager.updateSprint(currentSprint)
if (outcome.isInvalid()) {
log.error "Could not update sprint with name ${sprint.name}, ${outcome.getErrors()}"
} else {
log.warn "${sprint.name} has been closed."
}
}
}
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.