Get username logged in Jenkins from Jenkins Workflow (Pipeline) Plugin

后端 未结 10 655
忘了有多久
忘了有多久 2020-12-25 12:36

I am using the Pipeline plugin in Jenkins by Clouldbees (the name was Workflow plugin before), I am trying to get the user name in the Groovy script but I am not able to ach

10条回答
  •  野趣味
    野趣味 (楼主)
    2020-12-25 12:59

    I modified @shawn derik response to get it to work in my pipeline:

        stage("preserve build user") {
                wrap([$class: 'BuildUser']) {
                    GET_BUILD_USER = sh ( script: 'echo "${BUILD_USER}"', returnStdout: true).trim()
                }
            }
    

    Then I can reference that variable later on by passing it or in the same scope as ${GET_BUILD_USER} . I installed the same plugin referenced.

提交回复
热议问题