Execute script runner script from cmd line

We have a script which retrieves us the version history:

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.search.SearchProvider
import com.atlassian.jira.jql.parser.JqlQueryParser
import com.atlassian.jira.web.bean.PagerFilter
import com.atlassian.jira.user.util.DefaultUserManager
import com.atlassian.crowd.embedded.api.User
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.Issue
import com.atlassian.jira.ComponentManager
import java.text.SimpleDateFormat 
import java.util.Date

def jqlQueryParser = ComponentAccessor.getComponent(JqlQueryParser)
def searchProvider = ComponentAccessor.getComponent(SearchProvider)
def issueManager = ComponentAccessor.getIssueManager()
def userManager = ComponentAccessor.getUserManager();

// Adjust HERE the buildnumber to a certain version, where you want to retrieve all closed devs
def buildNumber = 7

def user = ComponentAccessor.getJiraAuthenticationContext().loggedInUser
def query = jqlQueryParser.parseQuery('project = DIV AND issuetype = Development AND status = Closed AND fixVersion = 2.8 AND "Build Number" ~ ' + buildNumber.toString())
def results = searchProvider.search(query, user, PagerFilter.getUnlimitedFilter())
def closedDevs = "";
def closedDevList = [];
def featureList = [];
def bugList = [];
results.getIssues().each {issue ->
    Issue parentIssue = issue.parentObject;
    def issueName = parentIssue.getIssueType().name.toUpperCase();
    def issueSummary = issue.getSummary();
    if (issueSummary.substring(0, 8) == "[DEV] - ")
    	issueSummary = issueSummary.substring(8, issueSummary.length());
    closedDevs += "* {{$issueName}} " + issueSummary + " {{JIRA|$issue.key}}<br>";
    def text = "* {{$issueName}} " + issueSummary + " {{JIRA|$issue.key}}";
    if (issueName == "FEATURE")
    	featureList << text;
        bugList << text;

def metadata = "=== Version 2.8.0 - Build $buildNumber ===<br>";
    metadata += "<br>";
    metadata += "Release: " + new Date().format('YYYY-MM-dd') + "<br><br>";

featureList.each {
    metadata += "${it}<br>";

bugList.each { 
    metadata += "${it}<br>";

return metadata;

 What we want to do now is, executing this script from the cmd line (windows batch) and retrieve the data. It must not be directly cmd line, but I need somehow the returned data in a text file.


1 answer

0 votes

Convert it into a "REST Endpoint" (mostly copy and paste I think), then you can poke JIRA any time you need it to pull back the output.

I was able to setup an endpoint.

However, I need an additional argument to setup the build number



I need to read out the number 49 and want to use it in my script.

How can I do this?

Sorry, missed the email earlier.

Yes, have a look through https://scriptrunner.adaptavist.com/latest/bitbucket/rest-endpoints.html

My reply was not accepted because of an inappropriate language or spam....

Thats why I have to paste the reply here:




The paste doesn't work, sorry.

Probably, but I don't know what it's got to do with the question.

What do you mean what its got to do with the quqestion?

I cannot parse the argument:

I get following error:

message    "Cannot cast object 'com.atlassian.plugin.servlet.PluginHttpRequestWrapper@631bb09c' with class 'com.sun.proxy.$Proxy2885' to class 'groovy.lang.Closure'"
stack-trace    "org.codehaus.groovy.runtime.typehandling.GroovyCastException: Cannot cast object 'com.atlassian.plugin.servlet.PluginHttpRequestWrapper@631bb09c' with class 'com.sun.proxy.$Proxy2885' to class 'groovy.lang.Closure'\n\tat com.onresolve.scriptrunner.runner.rest.common.CustomEndpointDelegate.methodMissing(CustomEndpointDelegate.groovy:20)\n\tat Script559$_run_closure1.doCall(Script559.groovy:30)\n\tat com.onresolve.scriptrunner.runner.rest.common.UserCustomScriptEndpoint.doEndpoint(UserCustomScriptEndpoint.groovy:308)\n\tat com.onresolve.scriptrunner.runner.rest.common.UserCustomScriptEndpoint.getUserEndpoint(UserCustomScriptEndpoint.groovy:193)\n"
status-code    "INTERNAL_SERVER_ERROR"


The error seems to be because of
def extraPath2 = getAdditionalPath(request)
You find everything inside the paste

@Nic Brough [Adaptavist]

Please help me, I cannot fix it without your help

Suggest an answer

Log in or Sign up to answer
Community showcase
Published Thursday in Bitbucket Pipelines

Building a Bitbucket Pipe as a casual coder

...ipe.sh :  #!/bin/bash source "$(dirname "$0")/common.sh" enable_debug extra_args="" if [[ "${DEBUG}" == "true" ]]; then extra_args="--verbose" fi # mandatory variables R...

233 views 0 12
Read article

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you