Forums

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

Scriptrunner : groovy, trying to use SwimlaneService and Swimlane

Olivier Billaud
Contributor
July 22, 2022

Hello dear friends, 

 

I'm stuck on groovy development about boards (rapid views), and more precisely on swimlanes.

I'm trying to add programmatically a new swimlane in my board.

For this, I found these classes:

https://docs.atlassian.com/jira-software/6.7.7/com/atlassian/greenhopper/service/rapid/view/SwimlaneServiceImpl.html

- https://docs.atlassian.com/jira-software/6.7.6/com/atlassian/greenhopper/model/rapid/Swimlane.SwimlaneBuilder.html

https://docs.atlassian.com/jira-software/6.7.7/com/atlassian/greenhopper/service/rapid/view/RapidViewServiceImpl.html

 

Here is my current code (it doesn't work at all):

import com.atlassian.greenhopper.model.rapid.RapidView
import com.atlassian.greenhopper.model.rapid.Swimlane
import com.atlassian.greenhopper.model.rapid.Swimlane.SwimlaneBuilder
import com.atlassian.greenhopper.service.rapid.view.RapidViewService
import com.atlassian.greenhopper.service.rapid.view.SwimlaneService
import com.atlassian.greenhopper.service.rapid.view.SwimlaneServiceImpl
import com.atlassian.jira.bc.JiraServiceContextImpl
import com.atlassian.jira.component.ComponentAccessor
import com.onresolve.scriptrunner.runner.customisers.JiraAgileBean


@JiraAgileBean

RapidViewService rapidViewService

def authenticationContext = ComponentAccessor.jiraAuthenticationContext
def user = authenticationContext.loggedInUser

def view = rapidViewService.getRapidView(user, 11014).get() // ID of board - you can see that in the URL

def swimlaneService = new SwimlaneServiceImpl()
log.debug swimlaneService;
log.debug view

allSwims = swimlaneService.loadSwimlanes(view)

for (swim in allSwims){
    log.debug swim.toString()
}

def newSwimBuilder = new SwimlaneBuilder()
newSwimBuilder.name("New swimlane")
newSwimBuilder.query("'parent link' = KEY-1")
newSwimBuilder.position(2 as Integer)
def newSwim = newSwimBuilder.build()

log.debug newSwim.getId()
log.debug newSwim.getName()
log.debug newSwim.getQuery()
log.debug newSwim.getPosition()

swimlaneService.add(user, view, newSwim)

 

Honestly, ... 

1. I found how to instantiate "rapidViewService" and it works, but I don't even understand how and why, first time I see this "@JiraAgileBean"... But nevermind. It works. But if you have time to explain to me what is this...

2. With SwimlaneService, I have the following error, after trying to access all swimlanes (loadSwimlanes(RapidView)) and I don't know why:

2022-07-22 16:11:20,224 ERROR [common.UserScriptEndpoint]: Script console script failed: java.lang.NullPointerException at com.atlassian.greenhopper.service.rapid.view.SwimlaneServiceImpl.loadSwimlanes(SwimlaneServiceImpl.java:84)

3. I found the "SwimlaneBuilder" and i can populate some fields (name, query...) but I don't know how to save it (and then, how to have a valid id for this new swimlane).

 

I'm pretty far from my goal. 

Please, help me if you can!

Thank you so much <3 love on you.

Oliv'

 

1 answer

0 votes
Nic Brough -Adaptavist-
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 Champions.
August 23, 2017

Have a look through https://confluence.atlassian.com/enterprise/jira-sizing-guide-461504623.html

Your VM is unsuitable though - you need a fast *local* disk to put the intex on, SAN attached storage is too slow.

testing
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
August 27, 2017

Dear Nic,

We are categorized as small-scale. Do you think that the features of our current server is too slow for such category?

Nic Brough -Adaptavist-
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 Champions.
August 27, 2017

I don't know, you've not told us how much memory you've got.

But it probably is, as you only need 1Gb heap space for a small server.

You just need to get a fast local disk attached and you'll be fine.

Suggest an answer

Log in or Sign up to answer