[英]Ordering of git child maven projects in Jenkins
I have a git projects having child projects. 我有一个子项目的git项目。
Sample representation: 样本表示:
parent
core
-src
-pom.xml
projA
-src
-pom.xml
projB
projB1
-src
-pom.xml
projB2
-src
-pom.xml
projC
-src
-pom.xml
pom.xml (parent pom)
projA
, projB1
, projB2
and projC
are independent projects which uses internally core
project. projA
, projB1
, projB2
和projC
是使用内部core
项目的独立项目。 In real, there are around 8-10 independent projects. 实际上,大约有8-10个独立项目。
I am using Jenkins for CI. 我正在将Jenkins用于CI。 I am using git plugin to fetch project details and maven plugin to build the project and run test cases. 我正在使用git插件来获取项目详细信息,并使用maven插件来构建项目并运行测试用例。
I am simply using clean install
goal. 我只是在使用clean install
目标。
Currently, I created a single job. 目前,我创建了一个工作。 some of the projects took more time (1-2 hours) to run all the test cases. 一些项目需要更多时间(1-2小时)来运行所有测试用例。 Using this approach, the order of execution of projects is random . 使用这种方法,项目的执行顺序是随机的 。
core
module I want to build other modules in parallel ( 2 or 3 at a time ) to fast build process. 构建core
模块后,我想并行构建其他模块(一次2个或3个 )以加快构建过程。 How can I achieve this? 我该如何实现? Running the maven build on the parent project is not exactly random. 在父项目上运行Maven构建并不是完全随机的。 As per the documentation : 根据文档 :
The Reactor 反应堆
The mechanism in Maven that handles multi-module projects is referred to as the reactor. Maven中处理多模块项目的机制称为反应堆。 This part of the Maven core does the following: Maven核心的这一部分执行以下操作:
- Collects all the available modules to build 收集所有可用模块以进行构建
- Sorts the projects into the correct build order 将项目分类为正确的构建顺序
- Builds the selected projects in order 按顺序构建所选项目
Reactor Sorting 反应堆分选
Because modules within a multi-module build can depend on each other, it is important that The reactor sorts all the projects in a way that guarantees any project is built before it is required. 由于多模块构建中的模块可以相互依赖,因此重要的是,反应堆必须以确保在需要之前构建任何项目的方式对所有项目进行排序。
The following relationships are honoured when sorting projects: 对项目进行排序时,应遵循以下关系:
- a project dependency on another module in the build 项目对构建中另一个模块的依赖
- a plugin declaration where the plugin is another modules in the build 插件声明,其中插件是构建中的另一个模块
- a plugin dependency on another module in the build 插件对构建中另一个模块的依赖
- a build extension declaration on another module in the build 构建中另一个模块上的构建扩展声明
- the order declared in the
<modules>
element (if no other rule applies)<modules>
元素中声明的顺序(如果没有其他规则适用)Note that only "instantiated" references are used - dependencyManagement and pluginManagement elements will not cause a change to the reactor sort order 请注意,仅使用“实例化”引用-dependencyManagement和pluginManagement元素不会导致更改反应堆的排序顺序
Given that it takes that long to build all of it, I suspect that you may be running some integration tests as well. 鉴于构建所有组件都需要花费很长时间,因此我怀疑您可能也在运行一些集成测试。 Thus, I'd try to isolate them and run everything during a nightly build, while running the (hopefully & desirably) fast unit test in a continuous integration build after each commit. 因此,我将尝试隔离它们并在每晚构建过程中运行所有程序,同时在每次提交后在连续集成构建中运行(希望且合乎需要的)快速单元测试。
Regarding the setup for parallelism, there are a few options which have one thing in common: creating a job for each of the modules. 关于并行性的设置,有几个选项有一个共同点:为每个模块创建作业。 To enumerate a few (you can read a nice description for some of them here ): 列举一些(您可以在此处阅读其中的一些不错的描述):
build whenever a SNAPSHOT dependency is built
trigger build whenever a SNAPSHOT dependency is built
build after other projects are built
trigger build after other projects are built
Personally I've used just the implicit upstream-downstream support for maven jobs & the snapshot dependency
trigger, meaning that Jenkins analyses the dependencies between the modules and triggers builds for the appropriate dependant jobs. 就我个人而言,我仅对Maven作业和snapshot dependency
触发器使用了隐式的上游-下游支持,这意味着Jenkins分析了模块之间的依赖关系,并为适当的依赖项触发了触发器的构建。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.