I am using the Pipeline plugin in Jenkins by Clouldbees (the name was Workflow plugin before), I am trying to get the user name in the Groovy script but I am not able to ach
Here's a slightly shorter version that doesn't require the use of environment variables:
@NonCPS def getBuildUser() { return currentBuild.rawBuild.getCause(Cause.UserIdCause).getUserId() }
The use of rawBuild requires that it be in a @NonCPS block.
rawBuild
@NonCPS