I need get the current log in user in Jenkins, I am using a Groovy parameter but I don't know how to get that,
Thanks,
You should be able to call:
import hudson.model.User ... User.current() From a groovy script to get the current user :-)
def user = build.causes[0].userId
build by itself doesn't exist it should be currentBuild.rawBuild.causes[0].userId, but thanks for pointing me in the right direction, User.current() does indeed return 'SYSTEM'. Have some points.import hudson.model.* def job = Jenkins.getInstance().getItemByFullName(env.JOB_BASE_NAME, Job.class) def build = job.getBuildByNumber(env.BUILD_ID as int) def userId = build.getCause(Cause.UserIdCause).getUserId() def user = User.current() println(user); println(userId); ----- this is the output [Pipeline] echo (hide) SYSTEM [Pipeline] echo eefrat [Pipeline] echo eefrat
User.current()?