Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Celebration

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root

Avatar

1 badge earned

Collect

Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!

Challenges
Coins

Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.

Recognition
Ribbon

Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!

Leaderboard

Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
4,467,455
Community Members
 
Community Events
177
Community Groups

How to create sprint on board with groovy script

Edited

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?

3 answers

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

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

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

 

Suggest an answer

Log in or Sign up to answer
TAGS

Atlassian Community Events