本文介绍了当子模块发生更改时如何触发jenkins中的构建?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们有一个带有外部子模块的git仓库。当子模块更改时,我们必须触发构建。您能否告诉我们如何使用您的xtrigger插件来轮询子模块上的更改。使用shell脚本或监视器文件或其他方法更好吗?






关于我们的构建过程的更多信息。
步骤#1。克隆根存储库与子模块
步骤#2。为每个子模块执行作业
步骤#2.1(在子模块中)。切换到正确的分支(例如master)
步骤#2.1(在子模块中)。现在如果有人提交到根存储库,jenkins启动应用程序
的构建,但是如果有人提交到任何子模块存储库,jenkins不会执行任何子模块存储库我们需要针对第二种情况的解决方案。在最好的情况下,它应该通过标准的jenkins功能或通过开源插件来完成。

指向该子模块中的特定提交(例如commit A )。因此,即使子模块发生变化,并且现在已经将 B 作为 A 的子项提交,您的顶级存储库仍然指向提交 A 。您必须明确地更新您的顶级存储库以指向子模块中的 B ,它不会自动发生。



鉴于此,您的问题的答案是,只需更新您的顶级存储库以指向新的提交 B 。这会导致你的版本库发生变化,它应该像通常那样触发Jenkins版本,这会从子模块中获取新的提交 B



-



考虑到额外的信息,我会添加一个Jenkins作业来监视子模块存储库。当一个子模块改变做任何子模块特定的测试,然后作为后期构建步骤触发主要的存储库作业。


We have a git repository with external submodules. We have to trigger a build when submodule was changed. Could you advice to us how to poll changes on submodules with your xtrigger plugin. Is it better to use shell script or monitor files or something else?


more information about our build brocess.step #1. clone root repository with submodulesstep #2. execute job for each submodulestep #2.1 (in submodule). switch to proper branch (for example, master)step #2.1 (in submodule). pull the latest sources for submodule

now if somebody commits to root repository, jenkins launches build for the appbut if somebody commits to any submodule repository, jenkins doesn't launch anything

we need solution for the second case. in best case it should be done via standard jenkins functionality or via open source plugin.

解决方案

When a git repository has a submodule it points to a specific commit in that submodule (say commit A). So even if the submodule changes and now has commit B as a child of A your top level repository is still pointing at commit A. You must explicitly update your top level repository to point at commit B in the submodule, it will not happen automatically.

Given this, the answer to your question is, just update your top level repository to point to the new commit B. This will cause a change in your repository which should trigger a Jenkins build just like it normally would, this will pick up the new commit B from the submodule.

--

Given the extra information I would add a Jenkins job that watches the submodule repositories. When a submodule changes do whatever submodule specific test you have then as a post build step trigger the main repository job.

这篇关于当子模块发生更改时如何触发jenkins中的构建?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-16 01:19