我有一个参数化的工作虚拟设备,可以正常工作。然后,我有多个作业调用具有特定参数集的作业A来运行(例如,作业B)。
比方说,作业虚拟脚本如下:
def jobLabel = "dummy-" + env.JOB_BASE_NAME.replace('/', '-').replace(' ', '_') + "${PARAM}"
currentBuild.displayName = "Dummy ${PARAM}"
echo "Previous result: " + currentBuild.previousBuild.result
if (currentBuild.previousBuild.result.equals("SUCCESS")) {
error("Build failed because of this and that..")
} else {
echo "Dummy ${PARAM}!"
}
和作业测试脚本如下:
// in this array we'll place the jobs that we wish to run
def branches = [:]
def environments = [
'US',
'EU',
'AU'
]
environments.each { env ->
branches["Dummy Tests " + env]= {
def result = build job: 'Dummy', parameters: [
string(name:'PARAM', value: env)
]
echo "${result.getResult()}"
if (result.getResult().equals("SUCCESS")) {
echo "Success! " + env
} else if (result.getResult().equals("FAILURE")) {
echo "Failure! " + env
}
}
}
parallel branches
上一个作业的结果是上一次执行的结果。我想以某种方式基于参数获取作业历史记录,以便我可以检测特定的作业组合何时从失败切换为成功,反之亦然,以进行通知。我想您可以对此进行回顾,但是对于希望成为普遍要求的事情来说听起来太复杂了。有任何提示或想法吗?