title: groovy.lang.MissingPropertyException: No such property: buildJobArray for class: groovy.lang.Binding
body: <p>I am new to groovy. Here i declared some list and using def keyword and use it in function to trigger a job and store it in list but it throws error :</p>
  <blockquote>
  <p>MissingPropertyException No such property: buildJobArray for class:
  groovy.lang.Binding</p>
  </blockquote>
  <p>Even if I declared a list. I don't understand whats wrong with my code</p>
  <pre><code>        def triggerBuildArray = []
          def buildJobArray = []
          def jobArray = []
          def paramsArray = []
          def noOfJob = 2 
  
          //function to trigger job
  
          def triggerJob(def job, def params, def jobNo) {
          
          buildJobArray &lt;&lt; job.scheduleBuild2(0, new Cause.UpstreamCause(build), new ParametersAction(params))
  
          println&quot;triggered job &quot;+jobNo;
          println&quot;waiting for completion of job &quot;+jobNo;
  
         }
  
          jobArray &lt;&lt; Hudson.instance.getJob('job1');
  
  
          //define parameters
  
          paramsArray &lt;&lt; [            
          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&lt;noOfJob;i++)
          {
              triggerJob(jobArray[i],paramsArray[i],i+1);
  
          }
  </code></pre>
  <p>but it gives error</p>
  <pre><code>        ERROR: Build step failed with exception
          groovy.lang.MissingPropertyException: No such property: buildJobArray for class: groovy.lang.Binding
              at groovy.lang.Binding.getVariable(Binding.java:63)
              at org.jenkinsci.plugins.scriptsecurity.sandbox.groovy.SandboxInterceptor.onGetProperty(SandboxInterceptor.java:242)
              at org.kohsuke.groovy.sandbox.impl.Checker$6.call(Checker.java:288)
              at org.kohsuke.groovy.sandbox.impl.Checker.checkedGetProperty(Checker.java:292)
              at org.kohsuke.groovy.sandbox.impl.Checker$checkedGetProperty$1.callStatic(Unknown Source)
              at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCallStatic(CallSiteArray.java:56)
              at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callStatic(AbstractCallSite.java:194)
              at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callStatic(AbstractCallSite.java:230)
              at Script1.triggerJob(Script1.groovy:19)
  </code></pre>
  <p><a href="https://i.stack.imgur.com/cYgCk.png" rel="noreferrer"><img src="https://i.stack.imgur.com/cYgCk.png" alt="enter image description here" /></a></p>