How to get the BUILD_USER in Jenkins when job triggered by timer?

后端 未结 14 1568
爱一瞬间的悲伤
爱一瞬间的悲伤 2020-12-09 03:01

I wanted to show the user who triggered a Jenkins job in the post job email. This is possible by using the plugin Build User Vars Plugin and the env variable

14条回答
  •  自闭症患者
    2020-12-09 03:23

    This gets the username who clicked "Build Now" in a Jenkins pipeline job.

    @NonCPS
    def getBuildUser() {
        return currentBuild.rawBuild.getCause(Cause.UserIdCause).getUserId()
    }
    

提交回复
热议问题