gpt4 book ai didi

maven - 如何将我的 Maven Jenkins 作业配置为仅构建已 checkin 代码的模块?

转载 作者:行者123 更新时间:2023-12-04 21:03:17 34 4
gpt4 key购买 nike

我正在使用 Maven 3.5、Git 和 Jenkins 2.138.1。我为我的多模块 Maven 项目设置了 Maven Jenkins 作业。通常,如果我只想在 Maven 中构建一个模块以及它会影响什么,我可以运行

mvn install -pl myModule -am

从命令行。我想做的是将我的 Jenkins 工作配置为仅在有人 checkin 特定模块的代码时才构建受影响的 Maven 模块及其依赖项,从而加快我的构建速度。如何在 Jenkins 中配置它?

最佳答案

如果您使用 FreeStyle 项目:
您需要安装 Maven 项目插件
然后有一个选项“ Incremental build-only Build changed modules

enter image description here

正如它所说,SCM 将处理哪些模块已被修改,并将仅构建这些模块。

如果是 Pipeline,则可以使用您提到的上述命令。 IE。

 mvn install -pl myModule -am

问题是在签到时知道要构建哪些模块
mvn install -amd -pl $(git status | grep -E "modified:|deleted:|added:" | awk '{print $2}' | cut -f1 -d"/")

上面的命令应该可以工作。

如果您要修改 pom.xml
您将需要 Maven 增量插件

下面的 URL 详细解释了如何使用 maven 实现这一点:
Jenkins building a product consisting of many Maven projects? (with Jenkins Pipeline plugin?)

希望能帮助到你 :)

关于maven - 如何将我的 Maven Jenkins 作业配置为仅构建已 checkin 代码的模块?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53545018/

34 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com