jenkins-bootstrap-jervis icon indicating copy to clipboard operation
jenkins-bootstrap-jervis copied to clipboard

Get user who triggerred Job DSL build

Open samrocketman opened this issue 8 years ago • 0 comments

There's two ways.

The user who caused the build is stored in a variable.

println "JENKINS_USER: ${JENKINS_USER}"

A more manual method for determining the user who triggered the Job DSL build. SEED_JOB is a binding for the current instance FreeStyle job. BUILD_NUMBER is a binding of the current running build (is a String).

import hudson.model.Cause.UserIdCause

triggered_by_userid = SEED_JOB.getBuildByNumber(BUILD_NUMBER as int).getCause(UserIdCause.class).getUserId()
println "Actual user: ${triggered_by_userid}"

samrocketman avatar Feb 14 '18 07:02 samrocketman