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











up vote
0
down vote

favorite












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 MissingPropertyException No such property: buildJobArray for class: groovy.lang.Binding, evenif i declared a list. I dont understand whats wrong with my 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 << job.scheduleBuild2(0, new Cause.UpstreamCause(build), new ParametersAction(params))

println"triggered job "+jobNo;
println"waiting 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);

}


but it gives error



        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)


enter image description here










share|improve this question







New contributor




Sumit Rane is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
























    up vote
    0
    down vote

    favorite












    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 MissingPropertyException No such property: buildJobArray for class: groovy.lang.Binding, evenif i declared a list. I dont understand whats wrong with my 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 << job.scheduleBuild2(0, new Cause.UpstreamCause(build), new ParametersAction(params))

    println"triggered job "+jobNo;
    println"waiting 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);

    }


    but it gives error



            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)


    enter image description here










    share|improve this question







    New contributor




    Sumit Rane is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
    Check out our Code of Conduct.






















      up vote
      0
      down vote

      favorite









      up vote
      0
      down vote

      favorite











      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 MissingPropertyException No such property: buildJobArray for class: groovy.lang.Binding, evenif i declared a list. I dont understand whats wrong with my 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 << job.scheduleBuild2(0, new Cause.UpstreamCause(build), new ParametersAction(params))

      println"triggered job "+jobNo;
      println"waiting 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);

      }


      but it gives error



              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)


      enter image description here










      share|improve this question







      New contributor




      Sumit Rane is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.











      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 MissingPropertyException No such property: buildJobArray for class: groovy.lang.Binding, evenif i declared a list. I dont understand whats wrong with my 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 << job.scheduleBuild2(0, new Cause.UpstreamCause(build), new ParametersAction(params))

      println"triggered job "+jobNo;
      println"waiting 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);

      }


      but it gives error



              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)


      enter image description here







      jenkins groovy






      share|improve this question







      New contributor




      Sumit Rane is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.











      share|improve this question







      New contributor




      Sumit Rane is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.









      share|improve this question




      share|improve this question






      New contributor




      Sumit Rane is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.









      asked Nov 19 at 13:20









      Sumit Rane

      52




      52




      New contributor




      Sumit Rane is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.





      New contributor





      Sumit Rane is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.






      Sumit Rane is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.
























          2 Answers
          2






          active

          oldest

          votes

















          up vote
          0
          down vote



          accepted










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

          println"triggered job "+jobNo;
          println"waiting 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);

          }





          share|improve this answer




























            up vote
            0
            down vote













            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.






            share|improve this answer








            New contributor




            Sumit Rane is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
            Check out our Code of Conduct.


















              Your Answer






              StackExchange.ifUsing("editor", function () {
              StackExchange.using("externalEditor", function () {
              StackExchange.using("snippets", function () {
              StackExchange.snippets.init();
              });
              });
              }, "code-snippets");

              StackExchange.ready(function() {
              var channelOptions = {
              tags: "".split(" "),
              id: "1"
              };
              initTagRenderer("".split(" "), "".split(" "), channelOptions);

              StackExchange.using("externalEditor", function() {
              // Have to fire editor after snippets, if snippets enabled
              if (StackExchange.settings.snippets.snippetsEnabled) {
              StackExchange.using("snippets", function() {
              createEditor();
              });
              }
              else {
              createEditor();
              }
              });

              function createEditor() {
              StackExchange.prepareEditor({
              heartbeatType: 'answer',
              convertImagesToLinks: true,
              noModals: true,
              showLowRepImageUploadWarning: true,
              reputationToPostImages: 10,
              bindNavPrevention: true,
              postfix: "",
              imageUploader: {
              brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
              contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
              allowUrls: true
              },
              onDemand: true,
              discardSelector: ".discard-answer"
              ,immediatelyShowMarkdownHelp:true
              });


              }
              });






              Sumit Rane is a new contributor. Be nice, and check out our Code of Conduct.










               

              draft saved


              draft discarded


















              StackExchange.ready(
              function () {
              StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53375533%2fgroovy-lang-missingpropertyexception-no-such-property-buildjobarray-for-class%23new-answer', 'question_page');
              }
              );

              Post as a guest















              Required, but never shown

























              2 Answers
              2






              active

              oldest

              votes








              2 Answers
              2






              active

              oldest

              votes









              active

              oldest

              votes






              active

              oldest

              votes








              up vote
              0
              down vote



              accepted










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

              println"triggered job "+jobNo;
              println"waiting 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);

              }





              share|improve this answer

























                up vote
                0
                down vote



                accepted










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

                println"triggered job "+jobNo;
                println"waiting 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);

                }





                share|improve this answer























                  up vote
                  0
                  down vote



                  accepted







                  up vote
                  0
                  down vote



                  accepted






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

                  println"triggered job "+jobNo;
                  println"waiting 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);

                  }





                  share|improve this answer












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

                  println"triggered job "+jobNo;
                  println"waiting 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);

                  }






                  share|improve this answer












                  share|improve this answer



                  share|improve this answer










                  answered Nov 19 at 20:18









                  Vihar Manchala

                  241




                  241
























                      up vote
                      0
                      down vote













                      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.






                      share|improve this answer








                      New contributor




                      Sumit Rane is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                      Check out our Code of Conduct.






















                        up vote
                        0
                        down vote













                        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.






                        share|improve this answer








                        New contributor




                        Sumit Rane is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                        Check out our Code of Conduct.




















                          up vote
                          0
                          down vote










                          up vote
                          0
                          down vote









                          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.






                          share|improve this answer








                          New contributor




                          Sumit Rane is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                          Check out our Code of Conduct.









                          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.







                          share|improve this answer








                          New contributor




                          Sumit Rane is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                          Check out our Code of Conduct.









                          share|improve this answer



                          share|improve this answer






                          New contributor




                          Sumit Rane is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                          Check out our Code of Conduct.









                          answered Nov 21 at 10:46









                          Sumit Rane

                          52




                          52




                          New contributor




                          Sumit Rane is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                          Check out our Code of Conduct.





                          New contributor





                          Sumit Rane is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                          Check out our Code of Conduct.






                          Sumit Rane is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                          Check out our Code of Conduct.






















                              Sumit Rane is a new contributor. Be nice, and check out our Code of Conduct.










                               

                              draft saved


                              draft discarded


















                              Sumit Rane is a new contributor. Be nice, and check out our Code of Conduct.













                              Sumit Rane is a new contributor. Be nice, and check out our Code of Conduct.












                              Sumit Rane is a new contributor. Be nice, and check out our Code of Conduct.















                               


                              draft saved


                              draft discarded














                              StackExchange.ready(
                              function () {
                              StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53375533%2fgroovy-lang-missingpropertyexception-no-such-property-buildjobarray-for-class%23new-answer', 'question_page');
                              }
                              );

                              Post as a guest















                              Required, but never shown





















































                              Required, but never shown














                              Required, but never shown












                              Required, but never shown







                              Required, but never shown

































                              Required, but never shown














                              Required, but never shown












                              Required, but never shown







                              Required, but never shown







                              Popular posts from this blog

                              Wiesbaden

                              Marschland

                              Dieringhausen