Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root


1 badge earned


Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!


Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.


Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!


Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
Community Members
Community Events
Community Groups

ScriptRunner class equivalents for Cloud

I'm trying to run a script in the Script Console, but I'm not able to access some of the classes I'm trying to import.

I've read in other articles that it is likely a difference between JIRIA Cloud and Server.


Is there an equivalent class that can be imported for the following?

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.jql.parser.JqlQueryParser
import com.atlassian.jira.web.bean.PagerFilter


My script in its entirety is as follows:


import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.jql.parser.JqlQueryParser
import com.atlassian.jira.web.bean.PagerFilter
import org.apache.log4j.Logger;

def jqlQueryParser = ComponentAccessor.getComponent(JqlQueryParser)
def searchProvider = ComponentAccessor.getComponent(SearchProvider)

def issueManager = ComponentAccessor.issueManager

def user = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser()

def projectKey = "CBE" //THE PROJECT KEY
def queryString = "project = ${projectKey}"

def query = jqlQueryParser.parseQuery(queryString)

def projectIssues =, user, PagerFilter.getUnlimitedFilter()).issues.key
def inputAccInitialEstimate = 'customfield_10134'
def valueAccInitialEstimate = issue.fields[inputAccInitialEstimate]['value'] as int

def inputNCInitialEstimate = 'customfield_10135'
def valueNCInitialEstimate = issue.fields[inputNCInitialEstimate]['value'] as int

def inputOthInitialEstimate = 'customfield_10136'
def valueothInitialEstimate = issue.fields[inputOthInitialEstimate]['value'] as int

def sumInitialEstimate = valueAccInitialEstimate + valueNCInitialEstimate + valueothInitialEstimate

def inputAccDetailEstimate = 'customfield_10152'
def valueAccDetailEstimate = issue.fields[inputAccDetailEstimate]['value'] as int

def inputNCDetailEstimate = 'customfield_10154'
def valueNCDetailEstimate = issue.fields[inputNCDetailEstimate]['value'] as int

def inputOthDetailEstimate = 'customfield_10155'
def valueothDetailEstimate = issue.fields[inputOthDetailEstimate]['value'] as int

def sumDetailEstimate = valueAccDetailEstimate + valueNCDetailEstimate + valueothDetailEstimate

def inputAccFinalEstimate = 'customfield_10156'
def valueAccFinalEstimate = issue.fields[inputAccFinalEstimate]['value'] as int

def inputNCFinalEstimate = 'customfield_10157'
def valueNCFinalEstimate = issue.fields[inputNCFinalEstimate]['value'] as int

def inputOthFinalEstimate = 'customfield_10163'
def valueothFinalEstimate = issue.fields[inputOthFinalEstimate]['value'] as int

def sumFinalEstimate = valueAccFinalEstimate + valueNCFinalEstimate + valueothFinalEstimate

def log = Logger.getLogger("com.onresolve.jira.groovy");

{ issueKey ->
def issue = issueManager.getIssueByCurrentKey(issueKey)

// Specify the issue key to update
//def issueKey = issue.getKey() ("Acc Detail Estimate: "+valueAccDetailEstimate); ("NC Detail Estimate: "+valueNCDetailEstimate); ("Oth Detail Estimate: "+valueothDetailEstimate); ("Total Detail: "+sumDetailEstimate); ("Acc Intial Estimate: "+valueAccInitialEstimate); ("NC Initial Estimate: "+valueNCInitialEstimate); ("Oth Initial Estimate: "+valueothInitialEstimate); ("Total Initial: "+sumInitialEstimate); ("Acc Intial Estimate: "+valueAccFinalEstimate); ("NC Final Estimate: "+valueNCFinalEstimate); ("Oth Final Estimate: "+valueothFinalEstimate); ("Total Final: "+sumFinalEstimate);

if(sumDetailEstimate > 2000 || sumInitialEstimate>2000 || sumFinalEstimate>2000)
// Specify the name of the select list field to set
def selectListFieldName = 'IT PM Audit Eligible Project? (2000+ hours)'

// Get the Custom field to get the option value from
def customField = get("/rest/api/2/field")
.find {
(it as Map).name == selectListFieldName
} as Map
// Check if the custom field returns a valid field and is not null
assert customField != null : "Cannot find custom field with name of: ${selectListFieldName}"

def result = put("/rest/api/2/issue/${issue.key}")
// Uncomment the line below if you want to set a field which is not pressent on the screen. Note - If using this you must run the script as the ScriptRunner Add-On User.
.queryString("overrideScreenSecurity", Boolean.TRUE)
.header('Content-Type', 'application/json')
fields: [
([value: "Yes"] as Map

if (result.status == 204) {
return "The ${} select list field was successfully updated on the ${issue.key} issue"
} else {
return "${result.status}: ${result.body}"


1 answer

1 accepted

0 votes
Answer accepted

Hi Matt,

Thank you for your question.

I can confirm that the reason that your code above will not work inside of ScriptRunner for Jira Cloud is due to the fact the code you have provided is fro ScriptRunner for Jira Server and uses the Java API which Atlassian provide only inside of Jira Server

The reason this code  will not work as Atlassian only provide a Rest API in Jira Cloud and does not provide a Java API in the cloud like they do in Jira Server.

You can see more detailed information on the differences between the cloud and server versions inside of our documentation page located here.

We would recommend reviewing the documentation for ScriptRunner for Jira Cloud which is located here along with the Jira Cloud Rest API Documentation in order to see how the REST API's work in Jira cloud.

This is the reason why your import statements and method calls to classes like the SearchProvider class cannot be resolved as the Java API's which provide these do not exist inside of Jira Cloud.

This means that you will need to re write your script to use the Rest API's for Jira cloud, but I can confirm you can make a JQL search by calling the Search for Issues Rest API and I can confirm we have an example of how to call this API inside the documentation page located here.

Also I can confirm you can call the Get Current User API to get the current user.

You will be able to take these examples and this information and use it to help create the equivalent script that you require for Jira Cloud.

I hope this information helps.



hi, now that we have Behaviours on Jira Cloud we can use groovy is there any update on this?

Suggest an answer

Log in or Sign up to answer
AUG Leaders

Atlassian Community Events