Instantly share code, notes, and snippets.

Embed
What would you like to do?
package examples
import com.atlassian.greenhopper.model.validation.ErrorCollection
import com.atlassian.greenhopper.service.rapid.view.RapidViewService
import com.atlassian.greenhopper.web.rapid.view.RapidViewHelper
import com.atlassian.jira.component.ComponentAccessor
import com.onresolve.scriptrunner.runner.customisers.JiraAgileBean
import com.onresolve.scriptrunner.runner.customisers.WithPlugin
@WithPlugin("com.pyxis.greenhopper.jira")
@JiraAgileBean
RapidViewService rapidViewService
@JiraAgileBean
RapidViewHelper rapidViewHelper
def currentUser = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser()
def errorCollection = new ErrorCollection()
def views = rapidViewService.getRapidViews(currentUser, errorCollection)
// list names of current boards
log.debug views*.name
// create a new board for project JRA
def projectIds = [ComponentAccessor.getProjectManager().getProjectObjByKey("JRA").id as String]
def outcome = rapidViewHelper.createRapidViewForPreset(currentUser, "Board for JRA", projectIds as Set, "scrum")
log.debug outcome
if (! outcome.isValid()) {
log.warn ("Failed to create board: ${outcome.errors}")
return
}
log.info ("Create board successfully.")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment