//Get the job
projectJob = Jenkins.instance.getItemByFullName('PathOf/DesiredJobToGetParamsOf/master/')
//Get last successful build
env = projectJob.getLastSuccessfulBuild().getEnvVars()
// In env you get a list like:
// [BRANCH_IS_PRIMARY:true,
// BRANCH_NAME:master,
// BUILD_DISPLAY_NAME:#29,
// BUILD_ID:29,<many more>...,
// param1:value1]
//Use the value of the desired parameter (e.g. "param1")
println(env["param1"])
//Output: "value1"
1条答案
按热度按时间a5g8bdjr1#
您可以使用Jenkins API获取以前构建的环境值,然后获取所需的参数: