Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Get user who triggerred Job DSL build #18

Open
samrocketman opened this issue Feb 14, 2018 · 0 comments
Open

Get user who triggerred Job DSL build #18

samrocketman opened this issue Feb 14, 2018 · 0 comments
Labels

Comments

@samrocketman
Copy link
Owner

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}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant