feat: add utils.hasChanges() utility method
This commit is contained in:
parent
fca4ac23d6
commit
170f143b00
|
@ -1,4 +1,5 @@
|
|||
import org.jenkinsci.plugins.pipeline.modeldefinition.Utils
|
||||
import org.jenkinsci.plugins.pipeline.modeldefinition.when.impl.ChangeSetConditional
|
||||
|
||||
void when(Boolean condition, body) {
|
||||
Map config = [:]
|
||||
|
@ -97,3 +98,20 @@ List<String> getProjectVersionTags(String overrideChannel = '') {
|
|||
Boolean isPR() {
|
||||
return env.BRANCH_NAME ==~ /^PR-.*$/
|
||||
}
|
||||
|
||||
|
||||
def hasChanges(String pattern) {
|
||||
def changeLogSets = currentBuild.changeSets
|
||||
def conditional = new ChangeSetConditional(pattern)
|
||||
|
||||
for (set in changeLogSets) {
|
||||
def entries = set.items
|
||||
for (entry in entries) {
|
||||
if (conditional.changeSetMatches(entry, pattern, true)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
Loading…
Reference in New Issue