stage(‘获取触发任务用户‘) {
steps {
script {
def BUILD_TRIGGER_BY = "${currentBuild.getBuildCauses()[0].shortDescription}"
BUILD_TRIGGER_BY = sh (script: "echo ${BUILD_TRIGGER_BY}|awk -F ‘ ‘ ‘{print $NF}‘", returnStdout: true).trim()
echo "BUILD_TRIGGER_BY: ${BUILD_TRIGGER_BY}"
}
}
}
参考至:https://*.com/questions/36194316/how-to-get-the-build-user-in-jenkins-when-job-triggered-by-timer