title: Get the latest successful commit ID in a declarative Jenkins pipeline
body: <p>I have a declarative Jenkins pipeline in my Jenkinsfile. I want to be able to do some logic based on the last commit that built successfully for that branch versus the current HEAD of the same branch.</p>
  
  <p>I am using the standard declarative checkout in a Jenkins multibranch pipeline. Each branch has a copy of the Jenkinsfile.</p>
  
  <p>What I have tried</p>
  
  <ol>
  <li>Using the environment variables exposed by the Git module. This did
  not work. The variables are not exposed in the pipeline.</li>
  <li>Digging through the internals of the injected currentBuild variable. The method I need to get the revision is unfortunately private and inaccessible. Whitelisting the internal build object that currentBuild wraps would gain me nothing (and yes I tried this). The same method is called by the thing that sets the environment variables.</li>
  </ol>
  
  <p>What is the approach here? I would like to retain the declarative checkout since it automatically chooses the correct branch</p>