Looking for options for coding large scriptrunner console scripts to combine custom field contexts

Kevin Ketchum May 5, 2021

I see plenty of discussion on tools for splitting projects into separate custom field contexts.

However, I have a need to move projects from one context to another context, and then updating the values of the fields so that they show correctly for the new context.

(if you just move a project to a new context, the field values display correctly, but when editing the record, they are not selected at all.  This is why I want to update the moved records to use the correct options for the new context)

I have both parts working individually:

  • I can move a project from one context to another
  • I can update the field value of the issues in the moved project, so that they show as chosen when editing the record.

However, both of these are somewhat complex (as least due to how I code)

I was wondering if there are any scripting tools that allow me to develop this work in a more IDEish way.  I know that IntelliJ was an option with ScriptRunner 6.0, but it seems this is no longer an option with later versions of ScriptRunner.

I'm not trying to write an addon, so I don't what to try to figure that out.

1 answer

1 accepted

0 votes
Answer accepted
Martin Bayer _MoroSystems_ s_r_o__
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
May 5, 2021

Hi @Kevin Ketchum we are using IDEA and it works nice. We need to create maven project to have dependencies available but it works.

You need to add at least Jira API dependency and groovy dependency:

<dependency>
   <groupId>com.atlassian.jira</groupId>
<artifactId>jira-api</artifactId>
<version>8.5.5</version>
</dependency>
<dependency>
<groupId>org.codehaus.groovy</groupId>
    <artifactId>groovy-all</artifactId>
    <version>3.0.6</version>
    <type>pom</type>
</dependency>

Is this what you're looking for?

Kevin Ketchum May 6, 2021

Thanks for the suggestion.

I spend some time looking into this and I wasn't successful in getting it to work.

I suppose staying within the scriptrunner console but working on my code structure will be a more effective use of my time now.

Martin Bayer _MoroSystems_ s_r_o__
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
May 6, 2021

Hi @Kevin Ketchum and what is the exact problem? You are not able to create maven project? Or you created it and it does not work?

Kevin Ketchum May 7, 2021

I was unable to figure out the code for managing customfields, and their contexts.

It's a knowledge limitation on my part, and I am probably over my head.

In any case, I thank you for responding and offering this information.

 

However, if you have any examples you'd be willing to share. I'd gladly review them to see they help me get beyond my limitations.

Martin Bayer _MoroSystems_ s_r_o__
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
May 7, 2021

Sure, I can try to help but do you have some code so we can discuss something real? :)

Kevin Ketchum May 7, 2021

In ScriptRunner Console, one of the basic scripts I run looks like this:

//Get the list of active users that do not have an employee number property set
import com.atlassian.jira.component.ComponentAccessor
def userPropertyManager = ComponentAccessor.getUserPropertyManager()
def userManager = ComponentAccessor.getUserManager()
def sb = new StringBuffer()
def uc = 0
sb.append("count,username,userkey,employee #<br>")
for (def user in userManager.allUsers) {
def employeenumber = userPropertyManager.getPropertySet(user).getString("jira.meta.Employee Number")
if (user.isActive() && employeenumber == null) {
sb.append(uc+ ",\"" +user.displayName + "\"," + user.getUsername() + "," + employeenumber + "<br>")
}
}
log.error("Found " + uc + " users with no Employee Number")
return sb.toString()

Obviously, running this outside of ScriptRunner, I would need to know what java classes to import and how to authenticate.

I am unfamiliar with these basic operations in IDEA.

Martin Bayer _MoroSystems_ s_r_o__
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
May 7, 2021

Thank you @Kevin Ketchum for your response. You can't run the script outside Jira. It must be deployed on Jira server because it must be ran under JVM process. But you can copy the script to server using SSH and just execute it.

Is it what you're looking for?

Kevin Ketchum May 7, 2021

OK - thanks for the info.  I'll see where that gets me.

Suggest an answer

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

Atlassian Community Events