[英]Jenkins Parallel Trigger and Wait
I have 4 jobs which needs to be executed in the following sequence 我有4个工作需要按以下顺序执行
JOB A
|------> JOB B
|------> JOB C
|------> JOB D
In the above 在上面
I tried the following plugins and couldn't achieve what I am looking for 我尝试了以下插件,无法实现我想要的
Is there any plugin which I haven't tried would help me in resolving this. 有没有我试过的插件可以帮助我解决这个问题。 Or is this can be achieved in a different way.
或者这可以通过不同的方式实现。 Please advise.
请指教。
Use DSL Script with Build Flow plugin. 将DSL脚本与Build Flow插件一起使用。
try this Example for your execution: 尝试此示例执行:
build("job A")
parallel
(
{build("job B")}
{build("job C")}
)
build("job D")
This may not be optimal way, but it should work. 这可能不是最佳方式,但应该有效。 Use the Parameterized Trigger Plugin.
使用参数化触发器插件。 To Job A, add a build step (NOT a Post Build Action) to start both Jobs B and C in the same build step AND block until they finish.
对于作业A,添加构建步骤(不是后构建操作)以在同一构建步骤和块中启动作业B和C,直到它们完成。 In Job C, add a build step (NOT a Post Build Action) that starts Job D AND blocks until it is finished.
在Job C中,添加一个构建步骤(不是Post Build Action),它启动Job D AND阻塞直到它完成。 That should keep Job A running for the full duration.
这应该让Job A在整个持续时间内运行。
This isn't really optimal though: Job A is held open waiting for B and C to finish. 但这并不是最佳选择:作业A保持打开状态等待B和C完成。 Then C is held open until D is finished.
然后C保持打开直到D完成。
Is there some reason that Job A needs to remain running for the duration? 工作A是否需要在此期间保持运行? Another possibility is to have Job A terminate after B and C are started, but have a Promotion on Job A that will execute your final actions after jobs B, C and D are successful.
另一种可能性是在B和C启动后使作业A终止,但在作业A上有一个促销,它将在作业B,C和D成功后执行您的最终操作。
I am trying to build a same system. 我正在尝试构建一个相同的系统。 I am building a certification pipeline where I need to run packager/build/deploy jobs and and corresponding test jobs.
我正在构建一个认证管道,我需要运行打包器/构建/部署作业和相应的测试作业。 When all of them are successful, I want to aggregate the test results and trigger the release job that can do an automated maven release.
当所有这些都成功时,我想聚合测试结果并触发可以执行自动maven发布的发布作业。
I selected Build pipeline plugin for visualization of the system. 我选择了Build管道插件来实现系统的可视化。 Initially tried with Parameterized trigger Plugin with blocking builds.
最初尝试使用带有阻塞构建的参数化触发器插件。 I could not setup archiving the artifacts/fingerprinting and downstream build relationship this way since archiving the artifacts works only in postbuild .
我无法以这种方式设置归档工件/指纹和下游构建关系,因为归档工件仅适用于postbuild 。 Then I put the Parameterized trigger in Post build activity.
然后我将参数化触发器放在Post构建活动中。 This way I was able to setup downstream builds, fingerprinting, aggregate test results but the build failures were not bubbling to upstream job chain and upstream jobs were non blocking
通过这种方式,我能够设置下游构建,指纹识别,聚合测试结果,但构建失败并未冒泡到上游作业链,上游作业无阻塞
I was finally able to achieve this using these plugins- 我终于能够使用这些插件实现这一目标 -
I'm using Jenkins 1.514 我正在使用Jenkins 1.514
System looks like this 系统看起来像这样
Trigger Job --> build (and deploy) Job (1..n) ---> Test Job (1..n) 触发作业 - >构建(和部署)作业(1..n)--->测试作业(1..n)
Trigger Job - 触发工作 -
Create as MultiJob and create a fingerprint file in shell exec 创建为MultiJob并在shell exec中创建指纹文件
echo date +%s
> fingerprint.txt echo
date +%s
> fingerprint.txt
Trick is that file needs to be archived during the build , to do that execute this script- 诀窍是该文件需要在构建期间归档 ,为此执行此脚本 -
ARCHIVEDIR=$JENKINS_HOME/jobs/$JOB_NAME/builds/$BUILD_ID/archive
mkdir $ARCHIVEDIR
cp fingerprint.txt $ARCHIVEDIR
In the trigger Job, use Join Plugin to execute the Release Job by choosing 'Run Post Build Actions at join' and execute the release project only on stable build of Trigger Job. 在触发器Job中,使用Join Plugin通过选择“在连接时运行Post Build Build”来执行Release Job,并仅在稳定构建Trigger Job时执行release项目。 This way all the steps are showing up in Build Pipeline view and Trigger job is blocking for all downstream builds to finish and sets its status as the worst downstream build to give a decision point for release job.
这样,所有步骤都显示在Build Pipeline视图中,Trigger作业阻止所有下游构建完成,并将其状态设置为最差的下游构建,以便为发布作业提供决策点。
Multijob Plugin Multijob插件
If you'd like to stop the mess with downstream / upstream jobs chains definitions. 如果你想停止下游/上游工作链定义的混乱。 Or when you want to add a full hierarchy of Jenkins jobs that will be executed in sequence or in parallel.
或者,当您想要添加将按顺序或并行执行的Jenkins作业的完整层次结构时。 Add context to your buildflow implementing parameter inheritance from the MultiJob to all its Phases and Jobs.
将上下文添加到构建流程中,实现从MultiJob到其所有阶段和作业的参数继承。 Phases are sequential while jobs inside each Phase are parallel.
阶段是连续的,而每个阶段内的工作是平行的。
https://wiki.jenkins-ci.org/display/JENKINS/Multijob+Plugin https://wiki.jenkins-ci.org/display/JENKINS/Multijob+Plugin
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.