我正在尝试获取在 Jenkinsfile 中运行构建的用户的名称:
...
user = User.current().getFullName()
...
但得到“系统”。
如何获得正确的用户名?
Jenkins 1.651.3
最佳答案
找到解决方案:
def build = currentBuild.rawBuild
def cause = build.getCause(hudson.model.Cause.UserIdCause.class)
def name = cause.getUserName()
echo "User: " + name
打印运行构建的用户名。
关于groovy - 如何知道哪个用户在 Jenkinsfile 中运行构建,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/38439058/