title: Jenkins - How to get and use upstream info in downstream
body: <p>Executing upstream job called "A". On success of A executing test cases which is downstream project "B". But while sending mail from B we have to incorporate upstream project details (upstream project name, build no) in mail. So we can easily map / corelate the test run with respective upstream job. </p>
  
  <p>In downstream project dashboard below details are displaying.</p>
  
  <pre><code>Started by upstream project Dev_RM_3.0_CI_Test build number 10
  originally caused by:
  </code></pre>
  
  <p>I checked in <a href="https://wiki.jenkins-ci.org/display/JENKINS/Building+a+software+project" rel="noreferrer">https://wiki.jenkins-ci.org/display/JENKINS/Building+a+software+project</a>. but couldnt find anything to inherit in downstream.</p>
  
  <p>Created sample job with below details to display the current job details.</p>
  
  <pre><code>echo $BUILD_NUMBER
  echo $JOB_NAME
  echo $BUILD_ID
  </code></pre>
  
  <p>But the output is</p>
  
  <pre><code>Building on master in workspace /var/lib/jenkins/workspace/env
  [env] $ /bin/sh -xe /tmp/hudson970280339057643719.sh
  + echo 1
  1
  + echo env
  env
  + echo 1
  1
  Finished: SUCCESS
  </code></pre>
  
  <ol>
  <li>Any help to inherit upstream details in downstream job?</li>
  <li>How to get current job details?</li>
  </ol>