Hi, I'm using Jenkins to run a bunch of self service jobs and need to be able to determine the user id of the person who ran a job.
We've been doing this with the scripted pipeline up until now by using the BuildUser plugin (quite why this isn't just a default exported variable I don't know, other CI servers do)
wrap([$class: 'BuildUser']) {
sh 'echo "${BUILD_USER}"'
sh 'echo "${BUILD_USER_ID}"'
sh 'echo "${BUILD_USER_EMAIL}"'
}
I can run the following within a step but the variable isn't available to subsequent steps.
steps {
wrap([$class: 'BuildUser']) {
sh 'echo "${BUILD_USER}"'
sh 'echo "${BUILD_USER_ID}"'
sh 'echo "${BUILD_USER_EMAIL}"'
}
echo "${USER_ID}"
Seems like there must be a way round this but can't find an answer in documentation or google, any help would be great.