我有 gitlab 仓库,在一个仓库下我有很多项目。现在我想将 gitlab 与 Jenkins 集成

I have gitlab repository, under one repository I have many projects. Now I want to intergrate gitlab with Jenkins

我有gitlab 仓库,在一个仓库下我有很多项目。现在我想将 gitlab 与 Jenkins 整合。因此,只要在 git 存储库中发生提交,存储库中的解决方案文件就应该构建。 但就我而言,如果我与 Jenkins 集成,我在同一 repository.so 中有许多解决方案文件,我只想触发与提交文件相关的解决方案文件。

他们是否通过使用 webhook(或任何方式)以任何方式知道存储库的哪个文件夹被修改了?这样我就可以根据路径

运行 相关的解决方案文件

文件夹结构: Project1/project1.sln 和依赖文件 Project2/project2.sln 和依赖文件

感谢 advance.and 还请指导 githab webhook 配置以与 Jenkins 集成。

GitLab Webhooks can be created in the GitLab Web-Interface. The modified files are listed in the body of the Push-Message.

使用 Git 插件的解决方案

  1. 为一个解决方案文件创建一个自由式作业,例如Project1
  2. 转到Build Trigges
  3. Select Poll SCM.
  4. Schedule留空
  5. 转到Source-Code-Management
  6. Select Git
  7. 配置存储库URL 和凭据
  8. 输入分支,例如refs/heads/master
  9. Select 存储库浏览器 (AUTO)
  10. 在其他行为处按Add底部的按钮
  11. Select Polling ignores commits in certain Paths
  12. 用项目文件夹的路径填写Included Regions,例如^Project1/*.。这意味着它只会在检测到该文件夹​​或其子文件夹中的更改时触发构建。
  13. 转到作业配置底部的 Post-Build Actions 并按 Add 按钮
  14. Select Clean Workspace after Build
  15. 添加Patterns for files to be deletedAdd按钮
  16. Select Exclude
  17. 输入**/.git/*
  18. Select 复选框 Apply pattern also on directories

当GitLab 发送推送消息时,Jenkins 将触发SCM 轮询此作业。它将验证相关文件夹中是否有更改。如果是这种情况,构建将开始。

您可以在 /job//scmPollLog/

查看 git 轮询协议

使用 GitLab 插件的解决方案

Jenkins GitLab Plugin 也是一个解决方案。