title: Get parameter of an other job in Pipeline
body: <p>I have two jobs. The first one is triggered manually with some parameters (for example a number which is needed). I have a second job which uses a paramter to select a particular build of the previous job (run parameter).</p>
  
  <p>Now I need to get the parameters from the first job (in this case the number) which I need for the second job as well. I want to prevent having the user to give the number parameter a second time. </p>
  
  <p>In the meantime I have found a way to extract the parameters from the first job via:</p>
  
  <pre><code>@NonCPS
  def getParameters(def item) {
      def result = ""
      def p = item?.actions.find{ it -&gt; it instanceof ParametersAction }?.parameters
      p.each { it -&gt;
          echo "parameter ${it.name}: ${it.value}"
          if (it.name.equals("NUMBER")) {
              result = it.value.toString()
          }
      }
      return result
  }
  ...
  
  node (..) {
  
  
      def item = hudson.model.Hudson.instance.getItem("${SELECTED_JOBNAME}")
      def number = Integer.parseInt("${SELECTED_NUMBER}")
      def x = item.getBuildByNumber(number)
  
      def newNumber = getParameters(x)
  </code></pre>
  
  <p>The problem which arises is getting the following:</p>
  
  <pre><code>parameter NUMBER: 16
  [Pipeline] echo
  org.jenkinsci.plugins.workflow.job.WorkflowJob@1776388d[XX-YY]
  [Pipeline] echo
  XX-YY #48
  [Pipeline] echo
  newNumber: 16
  [Pipeline] stage
  [Pipeline] { (First)
  [Pipeline] }
  [Pipeline] }
  [Pipeline] End of Pipeline
  java.io.NotSerializableException: org.jenkinsci.plugins.workflow.job.WorkflowJob
      at org.jboss.marshalling.river.RiverMarshaller.doWriteObject(RiverMarshaller.java:860)
      at org.jboss.marshalling.river.BlockMarshaller.doWriteObject(BlockMarshaller.java:65)
      at org.jboss.marshalling.river.BlockMarshaller.writeObject(BlockMarshaller.java:56)
      at org.jboss.marshalling.MarshallerObjectOutputStream.writeObjectOverride(MarshallerObjectOutputStream.java:50)
      at org.jboss.marshalling.river.RiverObjectOutputStream.writeObjectOverride(RiverObjectOutputStream.java:179)
      at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:343)
      at java.util.HashMap.writeObject(HashMap.java:1129)
  </code></pre>
  
  <p>I have already tried to use <code>@NonCPS</code> at serveral locations</p>
  
  <pre><code>node (..) {
  
      @NonCPS
      def item = hudson.model.Hudson.instance.getItem("${SELECTED_JOBNAME}")
      @NonCPS
      def number = Integer.parseInt("${SELECTED_NUMBER}")
      @NonCPS
      def x = item.getBuildByNumber(number)
      @NonCPS
      def newNumber = getParameters(x)
  </code></pre>
  
  <p>but with no luck. Does someone has an idea how to solve this issue? Maybe another way to get the parameters ?</p>