• Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: Major Major
    • groovy-plugin
    • None
    • Development

      Hi Team,

      Having issues in triggering Jenkins pipeline job from freestyle job using Groovy.

      I can able to successfully trigger  two freestyle jobs using groovy but not able to trigger parameterized pipeline job or parameter freestyle Job also from Jenkins free style job.

      Below is the error we are getting while triggering pipeline job from freestyle job.

       

      ERROR: Build step failed with exceptiongroovy.lang.MissingMethodException: No signature of method: org.jenkinsci.plugins.workflow.job.WorkflowJob.scheduleBuild2() is applicable for argument types: (java.lang.Integer, hudson.model.Cause$UpstreamCause, hudson.model.ParametersAction) values: [0, job/POC_SOA_GIT_Poller/16[hudson.triggers.SCMTrigger$SCMTriggerCause@3], ...]Possible solutions: scheduleBuild(), scheduleBuild2(int, [Lhudson.model.Action, scheduleBuild(int), scheduleBuild(int, hudson.model.Cause), scheduleBuild(hudson.model.Cause)

       

       

       

      Groovy Code which we used:

      import hudson.model.*
      import hudson.AbortException
      import hudson.console.HyperlinkNote
      import java.util.concurrent.CancellationException

      def build = Thread.currentThread().executable
      def TargetEnvironment="Test"

      println 'Tragte Env :' + TargetEnvironment
      def job = Hudson.instance.getJob('ParamPipeline')
      def anotherBuild
      try {
      def params = [
      new StringParameterValue('TargetEnvironment', TargetEnvironment),
      ]
      println(params)
      def future = job.scheduleBuild2(0,new Cause.UpstreamCause(build), new ParametersAction(params))
      println "Waiting for the completion of " + HyperlinkNote.encodeTo('/' + job.url, job.fullDisplayName)
      anotherBuild=future.get()
      } catch(Exception e) {
      throw e
      }

       

      Jenkins version 2.19.1

       

      Is there any issue in this version?

       

      JenkinsFile Pipeline code..: 

      parameters {
      string(defaultValue: '', description: 'Target Environment to deploy ', name: 'TargetEnvironment ')

      }
      node(){
      stage('Deploy Input Parameter Validation') {
      if(params.TargetEnvironment .length() != 0) {
      echo "$TargetEnvironment "
      }
      else {
      error "TargetEnvironment  value does not exist"
      }
      }
      }

       Screen shot attached.

       

      Regards

      Jayaram

          [JENKINS-45543] Not able to trigger Pipeline job

          jayaram s created issue -
          jayaram s made changes -
          Status Original: Open [ 1 ] New: In Progress [ 3 ]
          jayaram s made changes -
          Status Original: In Progress [ 3 ] New: Open [ 1 ]
          jayaram s made changes -
          Description Original: Hi Team,

          Having issues in triggering Jenkins pipeline job from freestyle job using Groovy.

          I can able to successfully trigger two freestyle jobs using groovy but not able to trigger pipeline job from Jenkins free style job.

          Below is the error we are getting while triggering pipeline job from freestyle job.

           

          {color:#d04437}ERROR: Build step failed with exception[groovy.lang.MissingMethodException|http://stacktrace.jenkins-ci.org/search?query=groovy.lang.MissingMethodException]: No signature of method: org.jenkinsci.plugins.workflow.job.WorkflowJob.scheduleBuild2() is applicable for argument types: (java.lang.Integer, hudson.model.Cause$UpstreamCause, hudson.model.ParametersAction) values: [0, job/POC_SOA_GIT_Poller/16[hudson.triggers.SCMTrigger$SCMTriggerCause@3], ...]Possible solutions: scheduleBuild(), scheduleBuild2(int, [Lhudson.model.Action;), scheduleBuild(int), scheduleBuild(int, hudson.model.Cause), scheduleBuild(hudson.model.Cause){color}

           

          The same if we trigger two freestyle jobs its works fine. We are passing the required parameters properly.

           

          Groovy Code which we used:

          def params = []
           
           params.push( new StringParameterValue('TargetEnvironment', TargetEnvironment ))
           params.push( new StringParameterValue('BuildOption', buildOption ))
           params.push( new StringParameterValue('bomcontent', bomFileContents ))




           jobName = "Pipeline Job"
           job = Hudson.instance.getJob(jobName)
           
           println "Launching $\{job.fullName}"
           future = job.scheduleBuild2(0, new Cause.UpstreamCause(build), new ParametersAction(params))
           future.get()

           

          Jenkins version 2.19.1

           

          Is there any issue in this version?

           

           

          Regards

          Jayaram
          New: Hi Team,

          Having issues in triggering Jenkins pipeline job from freestyle job using Groovy.

          I can able to successfully trigger two freestyle jobs using groovy but not able to trigger pipeline job from Jenkins free style job.

          Below is the error we are getting while triggering pipeline job from freestyle job.

           

          {color:#d04437}ERROR: Build step failed with exception[groovy.lang.MissingMethodException|http://stacktrace.jenkins-ci.org/search?query=groovy.lang.MissingMethodException]: No signature of method: org.jenkinsci.plugins.workflow.job.WorkflowJob.scheduleBuild2() is applicable for argument types: (java.lang.Integer, hudson.model.Cause$UpstreamCause, hudson.model.ParametersAction) values: [0, job/POC_SOA_GIT_Poller/16[hudson.triggers.SCMTrigger$SCMTriggerCause@3], ...]Possible solutions: scheduleBuild(), scheduleBuild2(int, [Lhudson.model.Action;), scheduleBuild(int), scheduleBuild(int, hudson.model.Cause), scheduleBuild(hudson.model.Cause){color}

           

          The same if we trigger two freestyle jobs its works fine. We are passing the required parameters properly.

           

          Groovy Code which we used:

          def params = []

          params.push( new StringParameterValue('TargetEnvironment', TargetEnvironment ))
           params.push( new StringParameterValue('BuildOption', buildOption ))
           params.push( new StringParameterValue('bomcontent', bomFileContents ))

          jobName = "Pipeline Job"
           job = Hudson.instance.getJob(jobName)

          println "Launching $\{job.fullName}"
           future = job.scheduleBuild2(0, new Cause.UpstreamCause(build), new ParametersAction(params))
           future.get()

           

          Jenkins version 2.19.1

           

          Is there any issue in this version?

           Pipeline Job code..

          These 3 parameters are created using Add Parameter also.

          Screen Shot attached.

          JenkinsFile:

           

          parameters \{
           string(defaultValue: '', description: 'Target Environment to deploy ', name: 'TargetEnvironment ')
           string(defaultValue: '', description: 'bomFileContents', name: 'bomcontent')
          string(defaultValue: '', description: 'buildOption', name: 'buildOption')

          }
          node()\{
           stage('Deploy Input Parameter Validation') \{
           if(params.bomcontent.length() != 0) \{
           echo "$bomcontent"
           }
           else \{
           error "bomcontent value does not exist"
           }
           }
          }

           

           

          Regards

          Jayaram
          jayaram s made changes -
          Attachment New: AddParameter.JPG [ 38911 ]
          jayaram s made changes -
          Description Original: Hi Team,

          Having issues in triggering Jenkins pipeline job from freestyle job using Groovy.

          I can able to successfully trigger two freestyle jobs using groovy but not able to trigger pipeline job from Jenkins free style job.

          Below is the error we are getting while triggering pipeline job from freestyle job.

           

          {color:#d04437}ERROR: Build step failed with exception[groovy.lang.MissingMethodException|http://stacktrace.jenkins-ci.org/search?query=groovy.lang.MissingMethodException]: No signature of method: org.jenkinsci.plugins.workflow.job.WorkflowJob.scheduleBuild2() is applicable for argument types: (java.lang.Integer, hudson.model.Cause$UpstreamCause, hudson.model.ParametersAction) values: [0, job/POC_SOA_GIT_Poller/16[hudson.triggers.SCMTrigger$SCMTriggerCause@3], ...]Possible solutions: scheduleBuild(), scheduleBuild2(int, [Lhudson.model.Action;), scheduleBuild(int), scheduleBuild(int, hudson.model.Cause), scheduleBuild(hudson.model.Cause){color}

           

          The same if we trigger two freestyle jobs its works fine. We are passing the required parameters properly.

           

          Groovy Code which we used:

          def params = []

          params.push( new StringParameterValue('TargetEnvironment', TargetEnvironment ))
           params.push( new StringParameterValue('BuildOption', buildOption ))
           params.push( new StringParameterValue('bomcontent', bomFileContents ))

          jobName = "Pipeline Job"
           job = Hudson.instance.getJob(jobName)

          println "Launching $\{job.fullName}"
           future = job.scheduleBuild2(0, new Cause.UpstreamCause(build), new ParametersAction(params))
           future.get()

           

          Jenkins version 2.19.1

           

          Is there any issue in this version?

           Pipeline Job code..

          These 3 parameters are created using Add Parameter also.

          Screen Shot attached.

          JenkinsFile:

           

          parameters \{
           string(defaultValue: '', description: 'Target Environment to deploy ', name: 'TargetEnvironment ')
           string(defaultValue: '', description: 'bomFileContents', name: 'bomcontent')
          string(defaultValue: '', description: 'buildOption', name: 'buildOption')

          }
          node()\{
           stage('Deploy Input Parameter Validation') \{
           if(params.bomcontent.length() != 0) \{
           echo "$bomcontent"
           }
           else \{
           error "bomcontent value does not exist"
           }
           }
          }

           

           

          Regards

          Jayaram
          New: Hi Team,

          Having issues in triggering Jenkins pipeline job from freestyle job using Groovy.

          I can able to successfully trigger  two freestyle jobs using groovy but not able to trigger parameterized pipeline job or parameter freestyle Job also from Jenkins free style job.

          Below is the error we are getting while triggering pipeline job from freestyle job.

           

          {color:#d04437}ERROR: Build step failed with exception[groovy.lang.MissingMethodException|http://stacktrace.jenkins-ci.org/search?query=groovy.lang.MissingMethodException]: No signature of method: org.jenkinsci.plugins.workflow.job.WorkflowJob.scheduleBuild2() is applicable for argument types: (java.lang.Integer, hudson.model.Cause$UpstreamCause, hudson.model.ParametersAction) values: [0, job/POC_SOA_GIT_Poller/16[hudson.triggers.SCMTrigger$SCMTriggerCause@3], ...]Possible solutions: scheduleBuild(), scheduleBuild2(int, [Lhudson.model.Action;), scheduleBuild(int), scheduleBuild(int, hudson.model.Cause), scheduleBuild(hudson.model.Cause){color}

           

           

           

          Groovy Code which we used:

          import hudson.model.*
          import hudson.AbortException
          import hudson.console.HyperlinkNote
          import java.util.concurrent.CancellationException

          def build = Thread.currentThread().executable
          def TargetEnvironment="Test"

          println 'Tragte Env :' + TargetEnvironment
          def job = Hudson.instance.getJob('ParamPipeline')
          def anotherBuild
          try \{
           def params = [
           new StringParameterValue('TargetEnvironment', TargetEnvironment),
           ]
           println(params)
           def future = job.scheduleBuild2(0,new Cause.UpstreamCause(build), new ParametersAction(params))
           println "Waiting for the completion of " + HyperlinkNote.encodeTo('/' + job.url, job.fullDisplayName)
           anotherBuild=future.get()
          } catch(Exception e) \{
           throw e
          }

           

          Jenkins version 2.19.1

           

          Is there any issue in this version?

           

          JenkinsFile Pipeline code..: 

          parameters \{
           string(defaultValue: '', description: 'Target Environment to deploy ', name: 'TargetEnvironment ')



          }
           node()\{
           stage('Deploy Input Parameter Validation') \{
           if(params.TargetEnvironment .length() != 0) \{
           echo "$TargetEnvironment "
           }
           else \{
           error "TargetEnvironment  value does not exist"
           }
           }
           }

           

           

          Regards

          Jayaram
          jayaram s made changes -
          Attachment Original: AddParameter.JPG [ 38911 ]
          jayaram s made changes -
          Description Original: Hi Team,

          Having issues in triggering Jenkins pipeline job from freestyle job using Groovy.

          I can able to successfully trigger  two freestyle jobs using groovy but not able to trigger parameterized pipeline job or parameter freestyle Job also from Jenkins free style job.

          Below is the error we are getting while triggering pipeline job from freestyle job.

           

          {color:#d04437}ERROR: Build step failed with exception[groovy.lang.MissingMethodException|http://stacktrace.jenkins-ci.org/search?query=groovy.lang.MissingMethodException]: No signature of method: org.jenkinsci.plugins.workflow.job.WorkflowJob.scheduleBuild2() is applicable for argument types: (java.lang.Integer, hudson.model.Cause$UpstreamCause, hudson.model.ParametersAction) values: [0, job/POC_SOA_GIT_Poller/16[hudson.triggers.SCMTrigger$SCMTriggerCause@3], ...]Possible solutions: scheduleBuild(), scheduleBuild2(int, [Lhudson.model.Action;), scheduleBuild(int), scheduleBuild(int, hudson.model.Cause), scheduleBuild(hudson.model.Cause){color}

           

           

           

          Groovy Code which we used:

          import hudson.model.*
          import hudson.AbortException
          import hudson.console.HyperlinkNote
          import java.util.concurrent.CancellationException

          def build = Thread.currentThread().executable
          def TargetEnvironment="Test"

          println 'Tragte Env :' + TargetEnvironment
          def job = Hudson.instance.getJob('ParamPipeline')
          def anotherBuild
          try \{
           def params = [
           new StringParameterValue('TargetEnvironment', TargetEnvironment),
           ]
           println(params)
           def future = job.scheduleBuild2(0,new Cause.UpstreamCause(build), new ParametersAction(params))
           println "Waiting for the completion of " + HyperlinkNote.encodeTo('/' + job.url, job.fullDisplayName)
           anotherBuild=future.get()
          } catch(Exception e) \{
           throw e
          }

           

          Jenkins version 2.19.1

           

          Is there any issue in this version?

           

          JenkinsFile Pipeline code..: 

          parameters \{
           string(defaultValue: '', description: 'Target Environment to deploy ', name: 'TargetEnvironment ')



          }
           node()\{
           stage('Deploy Input Parameter Validation') \{
           if(params.TargetEnvironment .length() != 0) \{
           echo "$TargetEnvironment "
           }
           else \{
           error "TargetEnvironment  value does not exist"
           }
           }
           }

           

           

          Regards

          Jayaram
          New: Hi Team,

          Having issues in triggering Jenkins pipeline job from freestyle job using Groovy.

          I can able to successfully trigger  two freestyle jobs using groovy but not able to trigger parameterized pipeline job or parameter freestyle Job also from Jenkins free style job.

          Below is the error we are getting while triggering pipeline job from freestyle job.

           

          {color:#d04437}ERROR: Build step failed with exception[groovy.lang.MissingMethodException|http://stacktrace.jenkins-ci.org/search?query=groovy.lang.MissingMethodException]: No signature of method: org.jenkinsci.plugins.workflow.job.WorkflowJob.scheduleBuild2() is applicable for argument types: (java.lang.Integer, hudson.model.Cause$UpstreamCause, hudson.model.ParametersAction) values: [0, job/POC_SOA_GIT_Poller/16[hudson.triggers.SCMTrigger$SCMTriggerCause@3], ...]Possible solutions: scheduleBuild(), scheduleBuild2(int, [Lhudson.model.Action;), scheduleBuild(int), scheduleBuild(int, hudson.model.Cause), scheduleBuild(hudson.model.Cause){color}

           

           

           

          Groovy Code which we used:

          import hudson.model.*
           import hudson.AbortException
           import hudson.console.HyperlinkNote
           import java.util.concurrent.CancellationException

          def build = Thread.currentThread().executable
           def TargetEnvironment="Test"

          println 'Tragte Env :' + TargetEnvironment
           def job = Hudson.instance.getJob('ParamPipeline')
           def anotherBuild
           try \{
           def params = [
           new StringParameterValue('TargetEnvironment', TargetEnvironment),
           ]
           println(params)
           def future = job.scheduleBuild2(0,new Cause.UpstreamCause(build), new ParametersAction(params))
           println "Waiting for the completion of " + HyperlinkNote.encodeTo('/' + job.url, job.fullDisplayName)
           anotherBuild=future.get()
           } catch(Exception e) \{
           throw e
           }

           

          Jenkins version 2.19.1

           

          Is there any issue in this version?

           

          JenkinsFile Pipeline code..: 

          parameters \{
           string(defaultValue: '', description: 'Target Environment to deploy ', name: 'TargetEnvironment ')

          }
           node()\{
           stage('Deploy Input Parameter Validation') \{
           if(params.TargetEnvironment .length() != 0) \{
           echo "$TargetEnvironment "
           }
           else \{
           error "TargetEnvironment  value does not exist"
           }
           }
           }

           Screen shot attached.

           

          Regards

          Jayaram
          jayaram s made changes -
          Attachment New: Capture1.JPG [ 38948 ]
          jayaram s made changes -
          Assignee Original: vjuranek [ vjuranek ] New: Stefan Wolf [ wolfs ]

            wolfs Stefan Wolf
            jayaram_s jayaram s
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated: