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?
@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 also need to specify the board with:
builder.rapidViewId(boardId);
The board-ID is included in the board's URL after the parameter rapidView.
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.
Spend the day sharpening your skills in Atlassian Cloud Organization Admin or Jira Administration, then take the exam onsite. Already ready? Take one - or more - of 12 different certification exams while you’re in Anaheim at Team' 25.
Learn more
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.