简体   繁体   English

詹金斯并行触发和等待

[英]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 在上面

  1. A should trigger B & C parallely and C inturn triggers D. A应该并行触发B&C,C inturn触发D.
  2. A should hold the job as running till all 3 of them completed. A应该保持工作运行直到所有3个工作完成。

I tried the following plugins and couldn't achieve what I am looking for 我尝试了以下插件,无法实现我想要的

  • Join Plugin 加入插件
  • Multijob Plugin Multijob插件
  • Multi-Configuration Project 多配置项目
  • Paramterized Trigger Plugin Paramterized Trigger插件

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- 我终于能够使用这些插件实现这一目标 -

  • Build Pipeline 构建管道
  • MultiJob Plugin MultiJob插件
  • FingerPrint Plugin FingerPrint插件
  • Copy Artifacts Plugin 复制Artifacts插件
  • Join Plugin 加入插件

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
  • Create MultiJob Phase consisting of build/deploy job. 创建由构建/部署作业组成的MultiJob阶段。
  • Build/deploy job is itself a multijob 构建/部署作业本身就是一个多工作
  • follow the same steps for creating build/deploy job as above relative to fingerprinting. 按照与上述相关的指纹创建构建/部署作业的步骤相同。
  • Copy the fingerprint.txt artifact from upstream job 从上游作业复制fingerprint.txt工件
  • Setup MultiJob phase in deploy job that triggers the test job 在触发测试作业的部署作业中设置MultiJob阶段
  • create a new fingerprint file and force archive it similar to above step 创建一个新的指纹文件并强制存档它类似于上面的步骤
  • Collect Junit results in the final test job. 收集Junit结果进行最终测试工作。


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.

相关问题 在 Jenkins 并行阶段中等待特定阶段完成 - Wait for specific stage to complete in Jenkins parallel stages Jenkins - 等待手动步骤与一些自动作业并行完成 - Jenkins - Wait for the manual step to finish in parallel with some automatic job 运行jenkins并行作业并从其他服务器等待 - run jenkins parallel job and wait from different servers Jenkins管道 - 如何在并行运行之间等待 - Jenkins pipeline - how to make wait between parallel running 如何在 groovy 中的 jenkins 并行作业之间进行等待 - How to make wait between jenkins parallel job in groovy Jenkins 声明式管道触发另一个构建,禁用它并等待它完成 - Jenkins declarative pipeline to trigger another build, disable it & wait for it to complete Jenkins Pipeline Plugin并行执行两个管道并使下游管道等待 - Jenkins Pipeline Plugin execute two pipelines in parallel and make downstream pipeline wait jenkins-如果需要,无法使用执行并发构建并行触发多个构建步骤 - jenkins - unable to trigger multiple build steps in parallel using the Execute concurrent builds if necessary 在Jenkins中如何触发具有不同属性文件作为参数的两个作业并并行运行它们? - How in Jenkins to trigger two jobs with different property files as parameters and run them in parallel? Jenkins只在完成一项工作后触发工作并避免并行执行工作 - Jenkins trigger a job only after one has completed and avoid parallel execution of jobs
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM