繁体   English   中英

如果仅在特定文件夹结构集而不是整个存储库上有任何 GIT 更改,如何触发 jenkins 作业

[英]How to trigger a jenkins job if there is any GIT changes only on specific set of folder structure not entire repo

我只有一个文件夹结构如下:

src (parent)

    test/resources

    main/resources

    test/java

    main/java

如果仅在 git 存储库中的 main/resources 或 test/resources 文件夹中有任何更改,我只想触发 Jenkins 作业。

实际上,那些资源只有测试数据表,如 xlsx 和 xml 格式的测试套件。 所以我只想在现有数据表中有任何新添加的数据表或更新时触发作业。

我不想为此工作代码。 只需要知道如何或想知道可以完成这项工作的插件。

您可以在每次提交后触发 jenkins 作业。

当您使用 git 执行各种操作时,会执行称为 git hooks 的脚本。

在这种情况下,您可以使用提交后挂钩。 你放在<your-project-location>/.git/hooks/post-commit任何脚本都会被执行。

假设您可以使用名为“trigger-jenkins.sh”的脚本触发 jenkins 作业,请将以下脚本放入位于<your-project-location>/.git/hooks/post-commit

#!/bin/bash
if git show | grep -E 'a/main/resources|a/test/resources'; then
        ./trigger-jenkins.sh
fi

确保您使提交后文件可执行

chmod +x <your-project-location>/.git/hooks/post-commit

现在每次你对 test/resources 和 main/resources 进行更改并提交时,git 将执行 trigger-jenkins.sh

暂无
暂无

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

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