Skip to content

Instantly share code, notes, and snippets.

@kohsuke
Created November 2, 2012 00:30
Show Gist options
  • Save kohsuke/3997848 to your computer and use it in GitHub Desktop.
Save kohsuke/3997848 to your computer and use it in GitHub Desktop.
Evaluate function
def evaluate(c) {
switch (c.model.name) {
case 'Or':
for (c2 in c.clauses) {
if (evaluate(c2)) {
return true
}
}
return false
case 'And':
for (c2 in c.clauses) {
if (!evaluate(c2)) {
return false
}
}
return true
case 'Nand':
for (c2 in c.clauses) {
if (!evaluate(c2)) {
return true
}
}
return false
case 'Log_Match':
return build.log.find(c.regex)
case 'File_Presence':
return build.workspace.child(c.file).exists()
}
assert false : c
}
result=evaluate(condition)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment