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

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 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]


0 answers

Suggest an answer

Log in or Sign up to answer
AUG Leaders

Atlassian Community Events