【发布时间】:2014-04-02 12:30:47
【问题描述】:
问题:我想在 groovy 中使用 RegEx 检查以下条件。 该脚本是用Jenkins Groovy postbuild plugin 脚本编写的。
String pattern is "JOB_EXIT : $RESULT"
检查逻辑:
If ( $RESULT contains only zeros ) {
// do something
} else if ( $RESULT contains only non-zeros ) {
// do something else
} else if ( $RESULT contains at least one zero and with some non-zeros ) {
// do something else
}
尝试失败:
def matcherFail = manager.getLogMatcher(".*JOB_EXIT : ([1-9]+)")
def matcherSuccess = manager.getLogMatcher(".*JOB_EXIT : ([0]*)")
if(matcherFail?.matches()) {
// do something
} else if(matcherSuccess?.matches()) {
// do something else
} else if(No idea about this one) {
// do something else
}
任何人都可以建议 RegEx 检查上述条件吗? 谢谢。
【问题讨论】:
标签: regex groovy jenkins post-build-event