Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

How to get board information resp. board objects by using a script (scriptrunner)

Günter Halmans September 30, 2020

Hi,

I tried to get all boards according to different projects by implementing a script in scriptrunner. Unfortunately, I'm not able to come to a result when I try to use BoardManager or BoardService.

Here is my code snippet:

projects.each{project->
log.debug"project: "+project.id
log.debug"project id class: "+project.id.getClass()
def b = boardManager.getBoardsForProjects(project.id)
log.debug(b)
}

 And here you see the error message:

2020-09-30 15_33_21-Script Console.png

I do not understand why the signature of the method "getBoardsForProjects()" is not correct.

Thanks for your support in advance!

Best regards,

Günter

3 answers

1 accepted

0 votes
Answer accepted
Günter Halmans October 1, 2020

Hi Niranjan,

in the meantime I found another solution (which I also have tried yesterday, but it did not work which might have been caused by a specific copy and paste error or for whatever reason...). Here - if someone is interesting in the solution to list all agile boards - is the code which I have used in the Console of Scriptrunner (see also script examples concerning Jira Agile (boards) - many thanks to the author!) :

import org.apache.log4j.Level
import org.apache.log4j.Category

import org.apache.log4j.Logger
def log = Logger.getLogger("01.10.20")
log.setLevel(Level.DEBUG)

import com.atlassian.jira.component.ComponentAccessor
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

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

def views = rapidViewService.getRapidViews(currentUser).value

// list names of current boards
views.each{board ->
log.debug(board.name)
}

BTW: I wasn't successful when I copied the code from create and link boards only. The compiler thrown an error and I had to add ".value" to  "def views = rapidViewService.getRapidViews(currentUser)". Now it works as intended.

I assume and hope that I can go further on this basis...we will see ;-)

Thanks a lot for your engagement!

Best regards,

Günter

0 votes
Günter Halmans September 30, 2020

Hi Niranjan,

oh what a silly typo...thanks for this hint!! Now I don't get an error message from the system anymore.

But to be honest, I only reached the next question...the list of the boards as a result of the boardManager method "getBoardsForProject()" is empty, although the projects have boards.

So I guess there is another problem beneath the typo...any additional idea?

Thanks!

Best regards,

Günter

Niranjan
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
September 30, 2020

@Günter Halmans - Could you try with entering one of the project ids directly? If that works, then we may need to look at the way how project ids are taken as input argument to the method.

Günter Halmans September 30, 2020

Hi Niranjan,

I have entered the id 18807, but the result is still the same: empty (and I know that there is a board existing ;-)

Here the snippet:

def b = boardManager.getBoardsForProject(18807)
log.debug(b)

result: []

I also tried...

def b = boardManager.getBoardsForProject(18807 as long)
log.debug(b)

...same result.

BR, Günter

0 votes
Niranjan
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
September 30, 2020

Hi @Günter Halmans - I believe that is getBoardsForProject(long projectId) and not getBoardsForProjects(project.id)

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
SERVER
TAGS
AUG Leaders

Atlassian Community Events