Search code examples
jenkinsgroovyjenkins-pluginsjenkins-groovy

How to get current Build_user in parameterized jenkins project


I want to get current Build user name into Active choice reactive parameter groovy script.

I have tried below code but its not working.

my project is parameterized.


Solution

  • Try the following:

    try {
        def user = hudson.model.User.current().getId()
        return [user]
    } catch (e)
    {
        return [e.toString()]
    }
    

    It is always better to use try and catch the exception in the groovy scripts, so as to figure out why it is not working.