[英]Configuring Jenkins to programmatically determine slave at build time from build parameter?
This is perhaps a slightly unusual Jenkins query, but we've got a project that spans many projects. 这也许是一个有点不寻常的Jenkins查询,但是我们有一个跨很多项目的项目。 All of them are Linux based, but they span multiple architectures (MIPS, SPARC, ARMv6, ARMv7).
它们都是基于Linux的,但是它们跨越多种体系结构(MIPS,SPARC,ARMv6,ARMv7)。
For a specific component, let's call it 'video-encoder', we'll therefore have 4 projects: mips-video-encoder, sparc-video-encoder, etc. 对于特定的组件,我们将其称为“视频编码器”,因此,我们将有4个项目:mips-video-encoder,sparc-video-encoder等。
Each project is built on 4 separate slaves with a label that correlates to their architecture, ie the MIPS slave has the labels 'mips' 'linux'. 每个项目都建立在4个独立的从站上,并带有与其架构相关的标签,即MIPS从站具有标签“ mips”,“ linux”。
My objectives are to: 我的目标是:
I have looked at the 'Multi-configuration' type job -- at the moment we are just using Single confguration jobs which are simple. 我已经看过“多配置”类型的作业-目前,我们仅使用简单的单一配置作业。 I am not sure if the Multi-configuration type allows for us to build only individual architectures at once.
我不确定多配置类型是否允许我们一次仅构建单个体系结构。 I had a play with the configuration matrix, but wasn't sure if this could be changed / adapted to just build a for single platform.
我玩过配置矩阵,但不确定是否可以更改/修改它以仅针对单个平台构建。 It looks like I may be able to use a Groovy statement to do this?
看来我可以使用Groovy语句来做到这一点? Something like:
就像是:
(label=="mips".implies("slave"=="mips")
Maybe that could be simplified to something like slave == label where label is the former name of the job when it was in its single-configuration state and is now a build parameter? 也许可以简化为诸如slave == label之类的东西,其中label是作业处于单一配置状态时的前一个名称,现在是一个构建参数?
I am thinking that we don't need a Multi-config job for this, if we can programatically choose the slave for this. 我认为,如果我们可以以编程方式为此选择从站,则我们不需要多配置作业。
I would greatly appreciate some advice on how we can consolidate the number of jobs we have and programatically change the target slave based on the architecture of the project which is a build parameter. 我非常感谢您提供一些建议,这些建议涉及如何合并已有的作业数量,并根据作为构建参数的项目体系结构以编程方式更改目标从站。
Many thanks in advance, 提前谢谢了,
You can make a wrapper job with a system groovy script. 您可以使用系统常规脚本进行包装工作。 You need the groovy plugin for this.
您需要为此使用groovy插件。 let call the wrapper job -
video-encoder-wrapper
, here are the bullets how to configure it: 让我们调用包装器作业
video-encoder-wrapper
,这是如何配置它的项目符号:
ARCH
ARCH
Assign the label to the video-encoder
job based on the ARCH
parameter by the step Execute system Groovy script
通过
Execute system Groovy script
步骤,根据ARCH
参数将标签分配给video-encoder
作业
import hudson.model.* encoder=Hudson.instance.getItem('video-encoder') def arch =build.buildVariableResolver.resolve("ARCH") label= Hudson.instance.getLabel(arch) encoder.setAssignedLabel(label)
Invoke non blocking downstream project video-encoder
, don't forget to pass the ARCH parameter 调用无阻塞的下游项目
video-encoder
,不要忘记传递ARCH参数
Set Build Name
in the video-encoder
job's configuration and set it to the something as ${ENV,var="ARCH"} - #${BUILD_NUMBER}
. video-encoder
作业的配置中检查选项Set Build Name
,并将其设置为${ENV,var="ARCH"} - #${BUILD_NUMBER}
。 It will allow you to track easily the build history. video-encoder-wrapper
job. video-encoder-wrapper
作业的并发构建。 It will prevent the assigning of 2 different labels in the same time to the video-encoder
job video-encoder
作业分配2个不同的标签 Hope it helps 希望能帮助到你
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.