I think the best solution is to use groovy with zero dependencies.
node { script{ def lastSuccessfulBuildID = 0 def build = currentBuild.previousBuild while (build != null) { if (build.result == "SUCCESS") { lastSuccessfulBuildID = build.id as Integer break } build = build.previousBuild } println lastSuccessfulBuildID } }
You do not need to specify jenkins_url or job_name, etc. to get the last successful build ID. Then you can easily use it in all Jenkinsfile repositories without unnecessary settings.
Tested on Jenkins v2.164.2
source share