从 Jenkins Workflow (Pipeline) Plugin 获取登录 Jenkins 的用户名 [英] Get username logged in Jenkins from Jenkins Workflow (Pipeline) Plugin

查看:40
本文介绍了从 Jenkins Workflow (Pipeline) Plugin 获取登录 Jenkins 的用户名的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 Jenkins 中使用 Clouldbees 的 Pipeline 插件(之前的名称是 Workflow 插件),我试图在 Groovy 脚本中获取用户名,但我无法实现.

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 achieve it.

stage 'checkout svn'

node('master') {
      // Get the user name logged in Jenkins
}

推荐答案

您是否尝试安装 构建用户变量插件?如果是这样,您应该可以运行

Did you try installing the Build User Vars plugin? If so, you should be able to run

node {
  wrap([$class: 'BuildUser']) {
    def user = env.BUILD_USER_ID
  }
}

或类似的.

这篇关于从 Jenkins Workflow (Pipeline) Plugin 获取登录 Jenkins 的用户名的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆