In my pipeline script I can access the current Build by using the currentBuild field. For Example,
node('remote'){
println currentBuild.getId()
println currentBuild.rawBuild
}
I assume that currentBuild refers to the RunWrapper Object and currentBuild.rawBuild refers to current Run object.
My question is, how does currentBuild get associated with the RunWrapper Class? Is there any way to directly access the RunWrapper Object other than through these fields?
Like its name suggests RunWrapper is a wrapper class on the actual Run object instance.
See the documentation for RunWrapper here
You may create a new RunWrapper instance anytime you like.