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.
More on Scripted pipeline, Groovy & CPS
What does a scripted pipeline look like and when would you still write one?IntermediateWhat is CPS and why does Jenkins transform pipeline Groovy?AdvancedWhy does `java.io.NotSerializableException` happen in pipelines?AdvancedWhat does `@NonCPS` do and what are its rules?AdvancedWhy do some Groovy closures behave unexpectedly in pipelines, for example `list.each { }` or `sort`?AdvancedWhat is the `script` block in declarative, and what are its limits?Beginner