如何在Gerrit触发器中触发Jenkins触发器更改为两个目录
问题描述:
我正在使用Gerrit触发器插件为Jenkins触发我的工作。如果文件夹1 和文件夹2中的文件发生更改,我只想触发我的作业。但就我的理解而言,通过以下配置,如果文件夹1 或文件夹2的文件发生更改,我们可以触发该作业。我怎样才能得到这个和条件?我会非常感谢你的帮助。如何在Gerrit触发器中触发Jenkins触发器更改为两个目录
Click here to See Gerrit Trigger Plugin Configuration Screenshot
答
作为一种变通方法,您可以获取对工作触发的变化,并检查是否变化都在做dirs.Continue只有当两个条件的满足。 groovy/pipeline的伪代码:
// get changes
sh 'git diff-tree --no-commit-id --name-only -r HEAD > changes.txt'
//create list from changes,each entry is
def file = readFile "changes.txt"
changed_files=file.split('\n')
//iterate over changed_files and check if trigger directories are present
//flag if found
//if conditions are met,continue with build