Created
November 2, 2012 00:30
-
-
Save kohsuke/3997848 to your computer and use it in GitHub Desktop.
Evaluate function
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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