title: Jenkins groovy pipeline - retrieve build number of built job
body: <p>I have a pipeline my team is using to spin up cloud VM's and deploy a software stack to them. Part of this process is to bundle up the artifacts from the builds they select. Right now im just grabbing last success of the jobs listed but ive encountered issues of that job being built again in another process before the pipeline can create its bundle, making the bundle grab an artifact built with the wrong dependencies. </p>
  
  <pre><code>def DeployModule(jobName, jobBranch, serverHostName, database){
  build job: jobName, parameters: [[$class: 'StringParameterValue', name: 'Branch', value: jobBranch], [$class: 'StringParameterValue', name: 'DatabaseAction', value: database], [$class: 'StringParameterValue', name: 'Profile', value: serverHostName]]
  println "$jobName Succesfull"
  }
  </code></pre>
  
  <p>Is there any way to alter my simple build job method to pull out the actual build number that was triggered? The pipeline console prints what build number is created im just not sure how to get it in my groovy code.</p>
  
  <pre><code>[Pipeline] build (Building tms-auto-build)
  Scheduling project: tms-auto-build
  Starting building: tms-auto-build #298
  </code></pre>