3

We have a Jenkins job that compiles our developers code each time they push to the repository and stores the build as an artifact (lets call it CompileApp). I have another job that smoke tests that code, copying the latest successful artifact from the build. However it cannot run against every single build due to resource constraints (call this job SmokeTest).

So SmokeTest executes periodically and each time it does I want to be able to set the build number of that job to the same build number of the CompileApp artifact I copied so that it is clear which build was tested. (I will also add a timestamp to the build number incase no builds have completed within this timeframe)

I can set the build number with the build name setter plugin which uses environment variables. But I am not sure how to access the CompileApp jobs build number using it. I have looked at the EnvInject plugin but haven't understood how to use it correctly.

Any advice and pointers would be very much appreciated.

4

5 回答 5

6

您可以使用 COPYARTIFACT_BUILD_NUMBER_ YOUR_JOB变量,其中YOUR_JOB是原始作业的名称。

于 2014-01-29T23:24:12.997 回答
2

最后通过使用批处理文件命令在 CompileApp 作业中编写一个小文本文件解决了我的问题

echo PARENT_BUILD_NUMBER=%BUILD_NUMBER% > envVariables.txt

然后我存档了那个文本文件。

然后在 SmokeTest 作业中,我从 CompileApp 复制了工件,并在构建步骤中使用 EnvInject 插件将其作为环境变量从文件中导入。然后有一个环境变量,我用它来设置构建名称和构建名称设置器插件和命令

#${ENV,var="PARENT_BUILD_NUMBER"} ${ENV,var="BUILD_ID"}

这个问题的答案对解决如何在Jenkins中设置环境变量问题特别有帮助?

于 2013-10-30T21:25:55.707 回答
1

Parameterized Trigger Plugin是您正在寻找的插件。使用此插件,您可以将BUILD_NUMBER当前作业的内容传递给下游作业。

于 2013-10-30T16:35:23.377 回答
0

我建议一个下游作业,在构建作业的同一工作区中运行,并且当集成测试作业运行时,它会阻止构建作业执行。

然后,您可以触发下游冒烟测试作业以每 5/10 次左右的构建运行一次。

于 2013-10-28T15:11:26.587 回答
0

查看这篇文章:如何说服詹金斯分享多个工作的内部版本号?

关键是使用EnvInject插件的“Evaluated Groovy Script”功能来获取对任何作业的引用。因此,在您的情况下,CompileApp 作业可以为 SmokeTestApp 作业设置 nextBuildNumber。

于 2014-04-12T18:09:04.030 回答