Answers: <p>Remove the quotes around <code>env.BUILD_NUMBER</code>.</p>
  
  <p>Instead of:</p>
  
  <pre><code>value: 'env.BUILD_NUMBER'
  </code></pre>
  
  <p>Try:</p>
  
  <pre><code>value: env.BUILD_NUMBER
  </code></pre>
  
Answers: CC BY-SA 4.0
Answers: 2018-11-13T17:57:31.937Z
Answers: 2018-11-13T17:57:31.937Z
Answers: jayhendren
Answers: <p>Looks like you're missing a plugin. Remove the <code>[$class: 'ScannerJobProperty', doNotScan: false]</code> portion. This works:</p>
  
  <p><em>Upstream Job</em></p>
  
  <pre><code>node {
      stage('Build parameters') {
          properties(
              [parameters(
                  [string(
                      defaultValue: '***', 
                      description: '', 
                      name: 'version', 
                      trim: false)
                  ])
              ])
      }
      echo env.BUILD_NUMBER
      def Latest_Build_Number = env.BUILD_NUMBER
      build(
          job: 'Downstream', 
          parameters: [
              [$class: 'StringParameterValue', 
               name: 'Latest_Build_Number', 
               value: env.BUILD_NUMBER, 
               propagate: false]
          ]
      )
  }
  </code></pre>
  
  <p><em>Downstream Job</em></p>
  
  <pre><code>node {
      stage('Downstream') {
          properties([
              parameters([string(
                  defaultValue: '', 
                  description: '', 
                  name: 'Latest_Build_Number', 
                  trim: false)
              ])
          ])
          echo Latest_Build_Number
      }
  }
  </code></pre>
  
Answers: CC BY-SA 4.0
Answers: 2018-11-15T04:18:33.723Z
Answers: 2018-11-15T04:18:33.723Z
Answers: primetheus
Answers: <p><strong>Build Failure Analyzer</strong> is the missing plugin name for this.</p>
  
Answers: CC BY-SA 4.0
Answers: 2022-08-18T04:54:42.523Z
Answers: 2022-08-18T04:55:14.707Z
Answers: 2022-08-18T04:55:14.707Z
Answers: Madhu Kulkarni
Body: <p>How to pass upstream build number to downstream job in Pipeline job using (Trigger parameter build on other projects) ? </p>
  
  <p>Agenda: To pass upstream job build number to downstream job to download upstream artefacts in downstream, here's my Jenkins pipeline script</p>
  
  <p>Upstream job script:</p>
  
  <pre><code>node 
  {
      stage('Build parameters')
      {
      properties([parameters([string(defaultValue: '***', description: '', name: 'version', trim: false)])])
      }/*
      echo env.BUILD_NUMBER
      def Latest_Build_Number=env.BUILD_NUMBER
      build job: 'Downstream', parameters: [[$class: 'StringParameterValue', name: 'Latest_Build_Number', value: 'env.BUILD_NUMBER', propagate:false]]    
  }
  
  **Downstream job script**:
  node 
  {
      stage('Downstream')
      {
      properties([[$class: 'ScannerJobProperty', doNotScan: false], parameters([string(defaultValue: '', description: '', name: 'Latest_Build_Number', trim: false)])])
  echo Latest_Build_Number
  }
  }
  
  Error: 
  *[Pipeline] {
  [Pipeline] properties
  [Pipeline] }
  [Pipeline] // node
  [Pipeline] End of Pipeline
  java.lang.UnsupportedOperationException: no known implementation of class hudson.model.JobProperty is named ScannerJobProperty
      at org.jenkinsci.plugins.structs.describable.DescribableModel.resolveClass(DescribableModel.java:478)
      at org.jenkinsci.plugins.structs.describable.DescribableModel.coerce(DescribableModel.java:402)
      at org.jenkinsci.plugins.structs.describable.DescribableModel.coerceList(DescribableModel.java:514)
      at org.jenkinsci.plugins.structs.describable.DescribableModel.coerce(DescribableModel.java:388)
      at org.jenkinsci.plugins.structs.describable.DescribableModel.buildArguments(DescribableModel.java:341)
      at org.jenkinsci.plugins.structs.describable.DescribableModel.instantiate(DescribableModel.java:282)
      at org.jenkinsci.plugins.workflow.steps.StepDescriptor.newInstance(StepDescriptor.java:201)
      at org.jenkinsci.plugins.workflow.cps.DSL.invokeStep(DSL.java:264)
      at org.jenkinsci.plugins.workflow.cps.DSL.invokeMethod(DSL.java:178)
      at org.jenkinsci.plugins.workflow.cps.CpsScript.invokeMethod(CpsScript.java:122)
      at sun.reflect.GeneratedMethodAccessor237.invoke(Unknown Source)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      at java.lang.reflect.Method.invoke(Method.java:498)
      at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:93)
      at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:325)
      at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1213)
      at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1022)
      at org.codehaus.groovy.runtime.callsite.PogoMetaClassSite.call(PogoMetaClassSite.java:42)
      at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:48)
      at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:113)
      at org.kohsuke.groovy.sandbox.impl.Checker$1.call(Checker.java:157)
      at org.kohsuke.groovy.sandbox.GroovyInterceptor.onMethodCall(GroovyInterceptor.java:23)
      at org.jenkinsci.plugins.scriptsecurity.sandbox.groovy.SandboxInterceptor.onMethodCall(SandboxInterceptor.java:155)
      at org.kohsuke.groovy.sandbox.impl.Checker$1.call(Checker.java:155)
      at org.kohsuke.groovy.sandbox.impl.Checker.checkedCall(Checker.java:159)
      at org.kohsuke.groovy.sandbox.impl.Checker.checkedCall(Checker.java:129)
      at com.cloudbees.groovy.cps.sandbox.SandboxInvoker.methodCall(SandboxInvoker.java:17)*
  </code></pre>
  
Tags: <jenkins-pipeline><jenkinsfile>
Title: Jenkins pipeline pass upstream build number to downstream job using Pipeline script
UserDisplayName: Srikanth Peddireddy
ThreadText: # Jenkins pipeline pass upstream build number to downstream job using Pipeline script
  
  (Asked by: username_0 on 2018-11-13)
  
  How to pass upstream build number to downstream job in Pipeline job using (Trigger parameter build on other projects) ?
  
  Agenda: To pass upstream job build number to downstream job to download upstream artefacts in downstream, here's my Jenkins pipeline script
  
  Upstream job script:
  
  ```
  node 
  {
      stage('Build parameters')
      {
      properties([parameters([string(defaultValue: '***', description: '', name: 'version', trim: false)])])
      }/*
      echo env.BUILD_NUMBER
      def Latest_Build_Number=env.BUILD_NUMBER
      build job: 'Downstream', parameters: [[$class: 'StringParameterValue', name: 'Latest_Build_Number', value: 'env.BUILD_NUMBER', propagate:false]]    
  }
  
  **Downstream job script**:
  node 
  {
      stage('Downstream')
      {
      properties([[$class: 'ScannerJobProperty', doNotScan: false], parameters([string(defaultValue: '', description: '', name: 'Latest_Build_Number', trim: false)])])
  echo Latest_Build_Number
  }
  }
  
  Error: 
  *[Pipeline] {
  [Pipeline] properties
  [Pipeline] }
  [Pipeline] // node
  [Pipeline] End of Pipeline
  java.lang.UnsupportedOperationException: no known implementation of class hudson.model.JobProperty is named ScannerJobProperty
      at org.jenkinsci.plugins.structs.describable.DescribableModel.resolveClass(DescribableModel.java:478)
      at org.jenkinsci.plugins.structs.describable.DescribableModel.coerce(DescribableModel.java:402)
      at org.jenkinsci.plugins.structs.describable.DescribableModel.coerceList(DescribableModel.java:514)
      at org.jenkinsci.plugins.structs.describable.DescribableModel.coerce(DescribableModel.java:388)
      at org.jenkinsci.plugins.structs.describable.DescribableModel.buildArguments(DescribableModel.java:341)
      at org.jenkinsci.plugins.structs.describable.DescribableModel.instantiate(DescribableModel.java:282)
      at org.jenkinsci.plugins.workflow.steps.StepDescriptor.newInstance(StepDescriptor.java:201)
      at org.jenkinsci.plugins.workflow.cps.DSL.invokeStep(DSL.java:264)
      at org.jenkinsci.plugins.workflow.cps.DSL.invokeMethod(DSL.java:178)
      at org.jenkinsci.plugins.workflow.cps.CpsScript.invokeMethod(CpsScript.java:122)
      at sun.reflect.GeneratedMethodAccessor237.invoke(Unknown Source)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      at java.lang.reflect.Method.invoke(Method.java:498)
      at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:93)
      at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:325)
      at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1213)
      at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1022)
      at org.codehaus.groovy.runtime.callsite.PogoMetaClassSite.call(PogoMetaClassSite.java:42)
      at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:48)
      at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:113)
      at org.kohsuke.groovy.sandbox.impl.Checker$1.call(Checker.java:157)
      at org.kohsuke.groovy.sandbox.GroovyInterceptor.onMethodCall(GroovyInterceptor.java:23)
      at org.jenkinsci.plugins.scriptsecurity.sandbox.groovy.SandboxInterceptor.onMethodCall(SandboxInterceptor.java:155)
      at org.kohsuke.groovy.sandbox.impl.Checker$1.call(Checker.java:155)
      at org.kohsuke.groovy.sandbox.impl.Checker.checkedCall(Checker.java:159)
      at org.kohsuke.groovy.sandbox.impl.Checker.checkedCall(Checker.java:129)
      at com.cloudbees.groovy.cps.sandbox.SandboxInvoker.methodCall(SandboxInvoker.java:17)*
  
  ```
  
  **Tags:** jenkins-pipeline, jenkinsfile
  
  
  ---
  
  ## 3 answers
  
  ### Answer by username_1 on 2018-11-13. Score: 2 | Accepted answer
  
  Remove the quotes around `env.BUILD_NUMBER`.
  
  Instead of:
  
  ```
  value: 'env.BUILD_NUMBER'
  
  ```
  
  Try:
  
  ```
  value: env.BUILD_NUMBER
  
  ```
  
  
  ---
  
  ### Answer by username_2 on 2018-11-15. Score: 0
  
  Looks like you're missing a plugin. Remove the `[$class: 'ScannerJobProperty', doNotScan: false]` portion. This works:
  
  *Upstream Job*
  
  ```
  node {
      stage('Build parameters') {
          properties(
              [parameters(
                  [string(
                      defaultValue: '***', 
                      description: '', 
                      name: 'version', 
                      trim: false)
                  ])
              ])
      }
      echo env.BUILD_NUMBER
      def Latest_Build_Number = env.BUILD_NUMBER
      build(
          job: 'Downstream', 
          parameters: [
              [$class: 'StringParameterValue', 
               name: 'Latest_Build_Number', 
               value: env.BUILD_NUMBER, 
               propagate: false]
          ]
      )
  }
  
  ```
  
  *Downstream Job*
  
  ```
  node {
      stage('Downstream') {
          properties([
              parameters([string(
                  defaultValue: '', 
                  description: '', 
                  name: 'Latest_Build_Number', 
                  trim: false)
              ])
          ])
          echo Latest_Build_Number
      }
  }
  
  ```
  
  
  ---
  
  ### Answer by username_3 on 2022-08-18. Score: 0
  
  **Build Failure Analyzer** is the missing plugin name for this.
  
  
  ---
  
  