问题描述
我有一个管道,可以在一个阶段中运行另一堆作业:
I have a pipeline which runs another bunch of jobs inside a stage:
node{
stage("building_other_components") {
build 'job1'
build 'job2' }}
如何恢复这些作业的内部版本号或URL?我只想通过邮件发送URL(例如: http://localhost:8080/job /job1/25 / last-changes/,我将添加 last-changes 部分)
谢谢,
How can I recover the build number or URL of these jobs? I just want to send the URL by mail ( Example: http://localhost:8080/job/job1/25/last-changes/ , I will add the last-changes part)
Thanks,
推荐答案
只要等待运行完成(默认为true
),就可以从build
步骤的返回值访问结果.返回值的类型为org.jenkinsci.plugins.workflow.support.steps.build.RunWrapper
( Javadoc ,源代码).您可以使用片段来查看build
步骤的帮助.生成器.
As long as you wait for the run to complete (defaults true
), you can access the result from the returned value of the build
step. The returned value is of the type of org.jenkinsci.plugins.workflow.support.steps.build.RunWrapper
(Javadoc, source code). You can see the help for the build
step by using the snippet generator.
以部分代码为例:
final job1Result = build('job1')
echo "Job 1 number: ${job1Result.number}"
final job2Result = build('job2')
echo "Job 2 number: ${job2Result.number}"
这使用 getNumber()
方法来获取已执行的运行次数.
This uses the getNumber()
method to get the number of the executed run.
这篇关于Jenkins:获取在管道内触发的Job的内部版本号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!