Interview Prep/Jenkins/Scripted pipeline, Groovy & CPS

What is the `currentBuild` global and what is useful on it?

IntermediateConceptScripted pipeline, Groovy & CPS
Answer

currentBuild is a RunWrapper for the running build: result, currentResult, number, displayName, description, durationString, previousBuild, changeSets, getBuildCauses(), buildVariables. We set currentBuild.displayName = "#${BUILD_NUMBER} ${TAG}" and currentBuild.description for readability. currentBuild.rawBuild exposes the internal Run object but needs script approval and should be avoided.

All Jenkins questions Roadmap: Jenkins

More on Scripted pipeline, Groovy & CPS