简体   繁体   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

I just have a folder structure as below:我只有一个文件夹结构如下:

src (parent)

    test/resources

    main/resources

    test/java

    main/java

I just want to trigger the Jenkins job if there is any change only in main/resources or test/resources folders from git repository.如果仅在 git 存储库中的 main/resources 或 test/resources 文件夹中有任何更改,我只想触发 Jenkins 作业。

Actually those resources having only test data sheets like xlsx and test suites which is in xml format.实际上,那些资源只有测试数据表,如 xlsx 和 xml 格式的测试套件。 So I just want to trigger a job if there is any newly added data sheet or updates in the existing data sheet.所以我只想在现有数据表中有任何新添加的数据表或更新时触发作业。

I didn't want working code for this.我不想为此工作代码。 Just need some idea how or wanna know plugins that will do this job.只需要知道如何或想知道可以完成这项工作的插件。

You can trigger the jenkins job after each commit.您可以在每次提交后触发 jenkins 作业。

There are scripts called git hooks that are executed when you take various actions using git.当您使用 git 执行各种操作时,会执行称为 git hooks 的脚本。

In this case you can use post-commit hook.在这种情况下,您可以使用提交后挂钩。 Whatever script you put at <your-project-location>/.git/hooks/post-commit will be executed.你放在<your-project-location>/.git/hooks/post-commit任何脚本都会被执行。

Assuming you can trigger the jenkins job using a script called "trigger-jenkins.sh", put the below script into post-commit file located in <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

make sure you make the post-commit file executable确保您使提交后文件可执行

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

now everytime you make a change to test/resources and main/resources and commit it, git will execute trigger-jenkins.sh现在每次你对 test/resources 和 main/resources 进行更改并提交时,git 将执行 trigger-jenkins.sh

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

相关问题 Jenkins如何确定GIT存储库中特定文件夹中的更改? - How Jenkins can determine change in a specific folder for a GIT repo? 当特定的Git存储库发生更改时,执行Jenkins工作(验收测试) - Executing Jenkins job (acceptance tests) when a specific Git repo gets changes 由于 Azure git 回购请求,触发 Jenkins 作业 - Trigger Jenkins job due to a Azure git repo pull request 当特定文件夹更改时在 Jenkins 中构建触发器 - Build trigger in Jenkins when a specific folder changes git repo的文件夹结构 - Folder structure for git repo Jenkins 和 Git:监控任何分支上的特定文件夹 - Jenkins and Git: Monitor specific folder on any branch 如何在 Jenkins 中签出具有特定修订版的 git repo - How to checkout git repo with an specific revision in Jenkins 基于签入到 teamcity 中 GIT 回购中的特定文件夹构建触发器 - build trigger based on checkins to specific folder in a GIT repo in teamcity 仅从存储库中获取特定文件夹,而不克隆整个存储库 - Obtain only a specific folder from a repository without cloning the entire repo 在git上,如何忽略已推送到原始仓库的特定文件夹,将更改推送到部署的仓库? - On git, how would I push changes to my deployed repo ignoring a specific folder that has already been pushed to my origin repo?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM