title: How to retrieve build_id of latest successful build in Jenkins?
body: <p>Generally, to get the artifact of the latest successful build, I do a <code>wget</code> on the below URL:</p>
  
  <p><a href="http://jenkins.com/job/job_name/lastSuccessfulBuild/artifact/artifact1/jenkins.txt" rel="noreferrer">http://jenkins.com/job/job_name/lastSuccessfulBuild/artifact/artifact1/jenkins.txt</a></p>
  
  <p>Is there a way, I can do a <code>wget</code> on <code>lastSuccessfulBuild</code> and get a <code>build_id</code> like below?</p>
  
  <pre><code>build_id=`wget http://jenkins.p2pcredit.local/job/job_name/lastSuccessfulBuild`
  </code></pre>