0
votes

I can't connect to Jenkins and execute script via Groovy Remote Plugin. I found only this documentation: https://wiki.jenkins-ci.org/display/JENKINS/Groovy+Remote+Control+Plugin

My example:

class GroovyDemo {

static void main(def args) {

    def transport = new HttpTransport("http://my-jenkins/plugin/groovy-remote/")
    def remote = new RemoteControl(transport)

    //1
    def result1 = remote {
        return jenkins.version.value
    }
    println "Jenkins version was ${result1}."

    //2
    def result2 = remote {
        return Jenkins.getInstance().getItems().size()
    }
    println "Jobs count: ${result2}."
}
}

I get the result:

Jenkins version was 1.580.3.
0

Why I get zero as number of jobs despite I have many jobs on my Jenkins?

Thanks

1

1 Answers

0
votes

You used different variable names for the Jenkins instance - lower case "jenkins" for the successful call and upper case "Jenkins" for the unsuccessful one.