首页 > 解决方案 > How does an &&, || work with jenkins pipeline groovy?

问题描述

I tried the below OR (||) to mark the build fail if any of the myTeststring1 OR myTeststring2 matches the console output. I tried few other ways with ||, it doesn't work. Any suggestion?

if (manager.logContains('.myTestString1.') || ('.myTestString2.')) { 
error("Build failed because of this and that..") 
}

I am trying to match two or more patterns to the Jenkins console output to mark build failure.

标签: jenkins-groovy

解决方案


试试下面的......在OR之后你需要提供一个表达式,在你的例子中你没有

  if (manager.logContains('.myTestString1.') || 
    manager.logContains('.myTestString2.')) { 
  error("Build failed because of this and that..") 
  }

推荐阅读