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,461,893
Community Members
 
Community Events
176
Community Groups

Create a board in Jira with Scriptrunner/Code

Hello,

as the title suggests, I simply want to create a board in my console with code in groovy. 

After searching for a while, I stumbled upon this code. But already the first line "@WithPlugin" fails me. Does anyone have a simple solution (can also be different than the code below) to creating a board in Jira? I really only want a board created, it does not need any other features. Thanks!

 

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
import com.atlassian.greenhopper.web.rapid.view.RapidViewResource.CreateResponse
import com.atlassian.greenhopper.web.rapid.view.RapidViewFilterHelper
import com.atlassian.greenhopper.web.rapid.view.RapidViewCreateModel
import com.atlassian.greenhopper.service.rapid.view.


@WithPlugin("com.pyxis.greenhopper.jira")

@JiraAgileBean
RapidViewService rapidViewService

@JiraAgileBean
RapidViewHelper rapidViewHelper

def currentUser = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser()
def errorCollection = new ErrorCollection()

// create a new board for project JRA
def projectIds = [ComponentAccessor.getProjectManager().getProjectObjByKey("ATP").id as String]
def outcome = rapidViewHelper.createRapidViewForPreset(currentUser, sourceIssue.summary + " Board", projectIds as Set, "scrum")
log.debug outcome

if (! outcome.isValid()) {
log.warn ("Failed to create board: ${outcome.errors}")
return
}

log.info ("Create board successfully.")

 

1 answer

Hi Sngy,

To create a new board using the ScriptRunner console, you will need to modify your code slightly as shown below:-

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.jiraAuthenticationContext.loggedInUser
def projectManager = ComponentAccessor.projectManager

def views = rapidViewService.getRapidViews(currentUser)

def projectIds = [projectManager.getProjectObjByKey("COM").id as String]
def outcome = rapidViewHelper.createRapidViewForPreset(currentUser, "Board for COM 2", projectIds as Set, "scrum")
log.debug outcome

if (! outcome.isValid()) {
log.warn ("Failed to create board: ${outcome.errors}")
return
}

Below is a print screen of the output:-

board.png

Your code appears to be failing because you do not have any variable initialised to invoke

sourceIssue.summary

Hope this helps to solve your question :)

Suggest an answer

Log in or Sign up to answer
TAGS

Atlassian Community Events