jenkins pipeline notes
获取触发用户:
def BUILDER_USER = "${currentBuild.getBuildCauses()[0].userId}"
由上游项目触发时获取上游项目构建信息和触发用户:
def BUILDER_USER = "${currentBuild.getBuildCauses()[0].userId}"
if (BUILDER_USER == "null") {
if (currentBuild.upstreamBuilds[0]) {
BUILDER_USER = "${currentBuild.upstreamBuilds[0].buildCauses.userId[0]}"
}
}
https://stackoverflow.com/questions/70291635/how-to-get-upstream-build-information-in-a-script-step-of-jenkins-classic-ui-pip
https://javadoc.jenkins.io/plugin/workflow-support/org/jenkinsci/plugins/workflow/support/steps/build/RunWrapper.html