Details

    • Type: Bug
    • Status: Open (View Workflow)
    • Priority: Major
    • Resolution: Unresolved
    • Component/s: groovy-plugin
    • Labels:
      None
    • Environment:
      Development
    • Similar Issues:

      Description

      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

        Attachments

          Activity

          Hide
          jayaram_s jayaram s added a comment -

          Any update please?

          Show
          jayaram_s jayaram s added a comment - Any update please?

            People

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

              Dates

              • Created:
                Updated: