0
votes

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.

I am using the standard declarative checkout in a Jenkins multibranch pipeline. Each branch has a copy of the Jenkinsfile.

What I have tried

  1. Using the environment variables exposed by the Git module. This did not work. The variables are not exposed in the pipeline.
  2. 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.

What is the approach here? I would like to retain the declarative checkout since it automatically chooses the correct branch

1

1 Answers

1
votes

As of the latest updates to the pipeline (updates as of 09-22-2017, Jenkins version 2.78), the bug preventing the git modules environment variables being exposed has been fixed making this no longer an issue.