我通过Jenkins管道触发了另一份工作。我需要在作业完成执行之前找到作业的URL。以下仅在作业完成后才起作用
result1 = build job: "$jobName", parameters: paramList
print result1.absoluteUrl
基本上我试图达到如下所示的目标
result1="NotSet"
parallel JobTrigger:{result1=build job: "$jobName", parameters: paramList},
checkJob:{
while(result1.equals("NotSet")){
Thread.sleep (3*1000)
print "Job is still not set"
}
triggeredJobURL=result1.absoluteUrl
print "triggeredJobURL: " + triggeredJobURL
emailext body: "Downstream job triggered URL:$triggeredJobURL", subject: 'Downstream job triggered', to: "${EMAIL_ADDRESS}"
答案 0 :(得分:1)
result1
是RunWrapper类型的变量
默认情况下(请参阅wait)父作业等待下游构建的完成。在这种情况下,步骤的返回值是RunWrapper
对象
如果是wait:false
,那么当前没有返回值。
对此Jenkins issue的评论描述了这个问题。
您可以从下游作业发送电子邮件(需要脚本批准):
triggeredJobURL = current.build.rawbuild.parent.url
emailext body: "Downstream job triggered URL:$triggeredJobURL", subject: 'Downstream job triggered', to: "${EMAIL_ADDRESS}"