Forums

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

Static type checking - You tried to call a method which is not allowed Error

Mohan Krishna
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!
July 12, 2023

Hello everyone, when I try to run this code in script runner, I got the [Static type checking] - You tried to call a method which is not allowed error.

import groovyx.net.http.ContentType
import groovyx.net.http.HTTPBuilder
import groovyx.net.http.Method
import com.onresolve.scriptrunner.runner.ScriptRunnerImpl


if ("myrepo" == "myrepo") {
String jenkinsUrl = "http://localhost:8089/"
String userName = 'admin'
String password = 'admin'
String targetJob = 'job1'

def http = new HTTPBuilder(jenkinsUrl)
String uspass = "$userName:$password".bytes.encodeBase64()
http.setHeaders([Authorization: "Basic $uspass"])

def crumb
http.get(path: 'crumbIssuer/api/xml') { response, xml ->
//crumb = xml.crumb.toString()
}
log.debug "Jenkins authorization crumb: $crumb"

http.headers += [
".crumb" : "crumb", //different versions of Jenkins take different versions of this header
"Jenkins-Crumb": ""
]

http.request(Method.POST, ContentType.TEXT) {
uri.path = "job/$targetJob/build"
query = [token: "kjabhdCFHFEBwhjfb7658sacdadfs", crumb: crumb]
}
}

image.png

1 answer

0 votes
pBogey August 14, 2025

so did you find out what the issue is? It's driving me mad.

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events