如果使用 findText 插件的任何测试用例失败,如何使 jenkins 构建失败
how to fail the jenkins build if any test cases are failed using findText plugin
我在 Jenkins 中有一个阶段如下,如果测试用例失败,如何将构建标记为失败或不稳定?我为 textfinder 插件生成了脚本管道,但它不起作用。 “findText alsoCheckConsoleOutput: true, regexp: 'There are test failures.', unstableIfFound: true”不确定将 textFinder regex 放在哪里。
管道{
agent none
tools {
maven 'maven_3_6_0'
}
options {
timestamps ()
buildDiscarder(logRotator(numToKeepStr:'5'))
}
environment {
JAVA_HOME = "/Users/jenkins/jdk-11.0.2.jdk/Contents/Home/"
imageTag = ""
}
parameters {
choice(name: 'buildEnv', choices: ['dev', 'test', 'preprod', 'production', 'prodg'], description: 'Environment for Image build')
choice(name: 'ENVIRONMENT', choices: ['dev', 'test', 'preprod', 'production', 'prodg'], description: 'Environment for Deploy')
}
stages {
stage("Tests") {
agent { label "xxxx_Slave"}
steps {
checkout([$class: 'GitSCM', branches: [[name: 'yyyyyyyyyyz']], doGenerateSubmoduleConfigurations: false, extensions: [], submoduleCfg: [], userRemoteConfigs: [[credentialsId: 'zzzzzzzzzzz', url: 'abcdefgh.git']]])
sh'''
cd dashboard
mvn -f pom.xml surefire-report:report -X -Dsurefire.suiteXmlFiles=src/test/resources/smoke_test.xml site -DgenerateReports=false
'''
}
}
}
}
为了使这个请求成为可能,我所做的一切如下:
在步骤块代码下方添加了一个 post 代码块。
post {
成功 {
findText alsoCheckConsoleOutput: true, refexp: 'There are test failures.', unstableIfFound: true
}
}
我在 Jenkins 中有一个阶段如下,如果测试用例失败,如何将构建标记为失败或不稳定?我为 textfinder 插件生成了脚本管道,但它不起作用。 “findText alsoCheckConsoleOutput: true, regexp: 'There are test failures.', unstableIfFound: true”不确定将 textFinder regex 放在哪里。
管道{
agent none
tools {
maven 'maven_3_6_0'
}
options {
timestamps ()
buildDiscarder(logRotator(numToKeepStr:'5'))
}
environment {
JAVA_HOME = "/Users/jenkins/jdk-11.0.2.jdk/Contents/Home/"
imageTag = ""
}
parameters {
choice(name: 'buildEnv', choices: ['dev', 'test', 'preprod', 'production', 'prodg'], description: 'Environment for Image build')
choice(name: 'ENVIRONMENT', choices: ['dev', 'test', 'preprod', 'production', 'prodg'], description: 'Environment for Deploy')
}
stages {
stage("Tests") {
agent { label "xxxx_Slave"}
steps {
checkout([$class: 'GitSCM', branches: [[name: 'yyyyyyyyyyz']], doGenerateSubmoduleConfigurations: false, extensions: [], submoduleCfg: [], userRemoteConfigs: [[credentialsId: 'zzzzzzzzzzz', url: 'abcdefgh.git']]])
sh'''
cd dashboard
mvn -f pom.xml surefire-report:report -X -Dsurefire.suiteXmlFiles=src/test/resources/smoke_test.xml site -DgenerateReports=false
'''
}
}
}
}
为了使这个请求成为可能,我所做的一切如下:
在步骤块代码下方添加了一个 post 代码块。
post { 成功 { findText alsoCheckConsoleOutput: true, refexp: 'There are test failures.', unstableIfFound: true } }