Hi Team, how can I get jira project boards with column names and status names in these columns using Adaptavist Scriptrunner for Jira Data Center
Hi @Chamdarig Dall
actually, there is some code to access the boards using ScriptRunner.
the following code can iterate over all boards and print out the mapping for each Status and also lists a mapping for the respective columns. This can be modified of course to what exactly is needed by your usecase:
import com.atlassian.greenhopper.model.rapid.Columnimport com.atlassian.greenhopper.service.rapid.view.RapidViewServiceimport com.atlassian.greenhopper.service.rapid.view.ColumnServiceimport com.atlassian.jira.component.ComponentAccessorimport com.atlassian.jira.issue.status.Statusimport com.onresolve.scriptrunner.runner.customisers.JiraAgileBeanimport com.onresolve.scriptrunner.runner.customisers.WithPlugin@WithPlugin("com.pyxis.greenhopper.jira")@JiraAgileBeanRapidViewService rapidViewService@JiraAgileBeanColumnService columnServicedef applicationUserInput = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser()if(rapidViewService) {def rapidViews = rapidViewService.getRapidViews(applicationUserInput).value rapidViews.each{ Map<Status, Column> columns = columnService.getColumnsByStatus(it) columns.each{Status status, Column column -> log.warn("Status name: ${status.name}") log.warn(" Column name: ${column.name}") log.warn(" Complete list of status IDs: ${column.statusIds.join(", ")}") log.warn("__________________")} }}
@Stefan Stadler you inspired me to develop this code:
import com.atlassian.greenhopper.model.rapid.Columnimport com.atlassian.greenhopper.service.rapid.view.RapidViewServiceimport com.atlassian.greenhopper.service.rapid.view.ColumnServiceimport com.atlassian.jira.component.ComponentAccessorimport com.atlassian.jira.issue.status.Statusimport com.onresolve.scriptrunner.runner.customisers.JiraAgileBeanimport com.onresolve.scriptrunner.runner.customisers.WithPlugin@WithPlugin("com.pyxis.greenhopper.jira")@JiraAgileBeanRapidViewService rapidViewService@JiraAgileBeanColumnService columnServicedef applicationUser = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser()// Your real board IDs here:def targetBoardIds = [1L, 2L]def htmlBuilder = new StringBuilder()htmlBuilder << "<table border='1' cellspacing='0' cellpadding='5' style='border-collapse: collapse;'>"htmlBuilder << "<thead><tr>"htmlBuilder << "<th>Board Name</th><th>Board ID</th><th>Column Name</th><th>Status Name</th>"htmlBuilder << "</tr></thead><tbody>"if (rapidViewService) {def rapidViews = rapidViewService.getRapidViews(applicationUser).valuerapidViews.findAll { it.id in targetBoardIds }.each { rapidView ->def columnsByStatus = columnService.getColumnsByStatus(rapidView)def columnStatusMap = [:]columnsByStatus.each { Status status, Column column ->columnStatusMap[column.name] = columnStatusMap.get(column.name, []) + status.name}columnStatusMap.each { columnName, statusNames ->statusNames.eachWithIndex { statusName, idx ->htmlBuilder << "<tr>"if (idx == 0) {htmlBuilder << "<td rowspan='${statusNames.size()}'>${rapidView.name}</td>"htmlBuilder << "<td rowspan='${statusNames.size()}'>${rapidView.id}</td>"htmlBuilder << "<td rowspan='${statusNames.size()}'>${columnName}</td>"}htmlBuilder << "<td>${statusName}</td>"htmlBuilder << "</tr>"}}}}htmlBuilder << "</tbody></table>"// Return the HTML resultreturn htmlBuilder.toString()
Hello @Chamdarig Dall
Big question for me here is: why use Scriptrunner as building the board you desire can be done in Jira right out of the box?Kind regards,Dick
I don't need it for building. I need it to get data about boards for reporting
A board is just a pair of glasses to look at the current status of a (part of a) project or projects. There's data in the work items.
When you're talking about reporting, you implicitly are interested in what has been done in past sprints. For this, Jira has the reporting section, where you can visualize metrics over past sprints. This section is full of handy charts and calculations, those of which you cannot obtain from boards in an easy manner. So why not start using sprints (or when you're more Kanban oriented, start using releases) and use the reporting section?Kind regards,Dick
Nope, I mean exactly what I wrote, "Get jira project boards with column names and status names in these columns"
I can get it via the REST API:
/rest/agile/1.0/board/{boardId}/configuration
But I was curious if I could get it with Scriptrunner
Thank you both! This is what I was looking for
It looks like you're new here. Sign in or register to get started.