jenkins - groovy.lang.MissingPropertyException: No such property: buildJobArray for class:

jenkins – groovy.lang.MissingPropertyException: No such property: buildJobArray for class: groovy.lang.Binding

jenkins – groovy.lang.MissingPropertyException: No such property: buildJobArray for class: groovy.lang.Binding

Here i found another way to do this. Here I used def keyword to define a variable due to use of def keyword it becomes local variable. If you dont use def keyword to variable it becomes global variable.

def buildJobArray = []   //local variable

buildJobArray = []  // Global variable

so once you used global variable it can be accessed from any function.

There is no Class implementation to hold the variables triggerBuildArray, buildJobArray, jobArray,paramsArray, noOfJob. In your case, you need to pass the object buildJobArray reference into function triggerJob.

Try the below code.

    def triggerBuildArray = []
    def buildJobArray = []
    def jobArray = []
    def paramsArray = []
    def noOfJob = 2 

    //function to trigger job

    def triggerJob(def job, def params, def jobNo, def buildJobArray) {

    buildJobArray << job.scheduleBuild2(0, new Cause.UpstreamCause(build), new ParametersAction(params))

    printlntriggered job +jobNo;
    printlnwaiting for completion of job +jobNo;

   }

    jobArray << Hudson.instance.getJob(job1);


    //define parameters

    paramsArray << [            
    new StringParameterValue(baseurl,build.getEnvironment(listener).get(ORAbaseurl)),
    new StringParameterValue(firm,build.getEnvironment(listener).get(ORAfirm)),
    new StringParameterValue(loginname,build.getEnvironment(listener).get(ORAloginname))

    ]

    for(int i=0;i<noOfJob;i++)
    {
        triggerJob(jobArray[i],paramsArray[i],i+1, buildJobArray);

    }

jenkins – groovy.lang.MissingPropertyException: No such property: buildJobArray for class: groovy.lang.Binding

Related posts on Array  :

Leave a Reply

Your email address will not be published.