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
James Littlefair
February 9, 2018

Hi there,

I'm a little confused by what you're asking here but I will try and provide some helpful info. As you mention URLs for trial, I'd assume you are using Jira Cloud.

If you have a cloud site trial setup, then your URL will remain the same once you purchase the 10 user licence.

When you licence a cloud instance, you are paying for this instance for a number of users for that site. Any number of these users can be admins - you don't pay for admin licences separately. 

You can find much more information about licencing of Jira Cloud here.

R
February 9, 2018

Hello James,

Can we discuss this over telephone? This will help both of us solve this doubt very easily. I am in India and you can reach me at +91-8861-403-605.

I have other questions too! Thank you so much for understanding and responding within short period of time.

Regards,

Rakesh Deshpande

James Littlefair
February 9, 2018

Hi Rakesh,

Apologies, but I'm not a member of Atlassian support - I am just a community member who is trying to help out - so I won't be phoning you. The community site here alongside the information on Atlassian's site regarding licencing should be sufficient to answer any of your questions.

If you have specific questions, try searching the community as you will find the majority of them have been answered before.

Hope this helps.

R
February 9, 2018

No problem, James.

Consider that I have created an account for 7 days i.e. xyz.atlassian.net and now I would be paying the amount of $10 where I will be able to have 10 admin members with the same URL link? so that all these admins will be able to make changes to the project assigned? Is my understanding correct?

Is this access only for 12 months ( 1 year ) or it is for lifetime after I make payment of $10? Can you please confirm on this because earlier most of my other co -workers has mentioned the same. Your clarification would help me to decide faster.

Again, Thank you for your quick response. !

James Littlefair
February 9, 2018

If you purchase licencing, you will be able to set all 10 of your users as admins if you so wish, and they will all be able to access Jira in full.

As the link I posted earlier describes, the $10 is a monthly payment to keep your cloud site active.

R
February 9, 2018

Thank you so much, James.

This is really helpful.

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events