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
@Stefan Stadler you inspired me to develop this code:
import com.atlassian.greenhopper.model.rapid.Column
import com.atlassian.greenhopper.service.rapid.view.RapidViewService
import com.atlassian.greenhopper.service.rapid.view.ColumnService
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.status.Status
import com.onresolve.scriptrunner.runner.customisers.JiraAgileBean
import com.onresolve.scriptrunner.runner.customisers.WithPlugin
@WithPlugin("com.pyxis.greenhopper.jira")
@JiraAgileBean
RapidViewService rapidViewService
@JiraAgileBean
ColumnService columnService
def 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).value
rapidViews
.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 result
return htmlBuilder.toString()
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.Column
import com.atlassian.greenhopper.service.rapid.view.RapidViewService
import com.atlassian.greenhopper.service.rapid.view.ColumnService
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.status.Status
import com.onresolve.scriptrunner.runner.customisers.JiraAgileBean
import com.onresolve.scriptrunner.runner.customisers.WithPlugin
@WithPlugin("com.pyxis.greenhopper.jira")
@JiraAgileBean
RapidViewService rapidViewService
@JiraAgileBean
ColumnService columnService
def 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("__________________")
}
}
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I don't need it for building. I need it to get data about boards for reporting
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.