简体   繁体   English

Jenkins / Hudson - 如何以超过1级深度并行运行多个作业?

[英]Jenkins/Hudson - How to run multiple jobs in parallel more than 1 level deep?

I'm trying to get the following workflow running in Jenkins, in parallel. 我正在尝试在Jenkins中并行运行以下工作流程。 So for example, both A and B running at the same time. 例如,A和B同时运行。 As soon as A finishes run A2 and A3 at the same time, etc... A一完成同时运行A2和A3等等......

It seems like a pretty common use case but most plugins I tried do no support more than 1 level deep, which is the case with the A branch below. 这似乎是一个非常常见的用例,但我尝试过的大多数插件都不支持超过1级深度,下面的A分支就是这种情况。 Join plug-in doesn't seem helpful here. 加入插件在这里似乎没有帮助。

I read about using the Promotion plugin but I'm a little mystified on what to fingerprint/artifacts to archive to make this work. 读到了有关使用Promotion插件的内容,但是我对有关指纹/工件的归档以使其工作有点神秘感。

Any clue on how to make this simple build pipeline work? 关于如何使这个简单的构建管道工作的任何线索?

流

As jgritty pointed out you could use the Build flow plugin . 正如jgritty所指出的,你可以使用Build flow插件 In order to get the type of parallel execution you want you could run something equivalent to the following build flow script: 为了获得您想要的并行执行类型,您可以运行与以下构建流程脚本等效的内容:

buildTrigger = build("Trigger")

parallel(
    {
        buildA = build("A")
        buildA1 = build("A1")
        parallel(
            {
                buildA2 = build("A2")
            },
            {
                buildA3 = build("A3")
            },
        )
    },
    {
        buildB = build("B")
        buildB1 = build("B1")
    },
)

buildResults = build("GatherResult")

In this script the first parallel block takes care of the A and B branches. 在此脚本中,第一个parallel块负责A和B分支。 Once in a branch each build is sequential until you add more parallel blocks. 进入分支后,每个构建都是顺序的,直到您添加更多parallel块。

There is a solution which works great: the Multi-Job plugin . 有一个很好的解决方案: Multi-Job插件 It does exactly what you want. 它完全符合你的要求。 With The MultiJob Plugin you can split your job into phases which run serially. 使用MultiJob插件,您可以将作业分成连续运行的阶段。 Within each phase, the jobs run in parallel. 在每个阶段中,作业并行运行。

For simplicity I'm going to assume that A and B are "compilation jobs" you wish to run in parallel. 为简单起见,我将假设A和B是您希望并行运行的“编译工作”。 Further assume there may be an A-Test (and its children) and B-Test which are also separate jobs. 进一步假设可能存在A-Test(及其子项)和B-Test,它们也是独立的工作。

You create the multijob as follows: New Item -> Multijob Project 您可以按如下方式创建多工具:New Item - > Multijob Project

In the project you create two phases (Add build step "MultiJob Phase"). 在项目中,您将创建两个阶段(添加构建步骤“MultiJob阶段”)。 The first will be COMPILE and you would add Phase Job's "A" and "B". 第一个是COMPILE,你会添加Phase Job的“A”和“B”。

You can change the options for the COMPILE phase jobs so that if either fails, the whole phase aborts (the default), or allow the job to continue. 您可以更改COMPILE阶段作业的选项,以便在任一阶段失败时,整个阶段中止(默认),或允许作业继续。

MultiJob设置

Next you add another MultiJob Phase Build step for TEST and add "A-Test" and "B-Test" to that. 接下来,为TEST添加另一个MultiJob Phase Build 步骤 ,并为其添加“A-Test”和“B-Test”。 Remember that A, B, A-Test, and B-Test are all separate jobs that can also be run individually if desired. 请记住,A,B,A-Test和B-Test都是单独的作业,如果需要,也可以单独运行。

That's it. 而已。 When the job runs it will contain links to the child jobs so you can see what happened with the sub-jobs. 作业运行时,它将包含子作业的链接,以便您可以查看子作业发生的情况。

我相信可能是你需要的插件。

I had a similar problem, and the Promoted Builds Plugin was a better solution for me than the Build Flow Plugin that others have advised. 我遇到了类似的问题,与其他人建议的Build Flow插件相比, Promoted Builds Plugin对我来说是一个更好的解决方案。

A build promotion job can be added to an existing job by ticking the check-box "Promote builds when...". 通过勾选“在...时提升构建”复选框,可以将构建升级作业添加到现有作业中。 You can configure the promotion to occur when named downstream projects are complete by checking "When the following downstream projects build successfully" under Criteria (assuming that all downstream projects are related by fingerprints). 您可以通过在Criteria下选中“当下面的下游项目成功构建时”(假设所有下游项目都通过指纹相关联)来配置在命名下游项目完成时发生的促销。

At the promotion step, you can trigger emails of summary results or trigger a further downstream job. 在促销步骤中,您可以触发摘要结果的电子邮件或触发进一步的下游作业。

In this case, you might add the promotion job to the Trigger projects, and depend on projects A2 A3 and B1 completing successfully. 在这种情况下,您可以将促销作业添加到Trigger项目,并依赖于项目A2 A3和B1成功完成。

Use Build Other projects in Post-Build Section. 在Post-Build Section中使用Build Other项目。 Say start A2,A3 on completion of A1. 说A1完成后开始A2,A3。 Increase number of executors in Manage Hudson --> Configure system to appropriate number. 增加Manage Hudson中的执行程序数 - >将系统配置为适当的数字。

We have a set up similar to what 'Steven the Easily Amused' suggested. 我们的设置类似于“Steven the Easyly Amused”所建议的。 Except I set up the "A" and "B" paths as their own Multi-Job stack and another Multi-Job set up as the "Trigger". 除了我将“A”和“B”路径设置为他们自己的多工作堆栈而另一个多工作设置为“触发器”。 Where both the "A" and "B" stack run in parallel. “A”和“B”堆栈并行运行。 This way they don't directly have a tight dependency on each other. 这样他们就不会直接相互依赖。 You can also aggregate your results depending on if one/both stacks fail. 您还可以根据一个/两个堆栈是否失败来聚合结果。 You can also set up the "Trigger" to collect parameters and pass then to both stacks. 您还可以设置“触发器”来收集参数,然后传递给两个堆栈。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM