为什么测试失败会导致Allure插件将整个Jenkins版本标记为“不稳定”?

时间:2019-06-24 20:51:26

标签: jenkins cucumber jenkins-pipeline allure

我已经设置了将运行Cucumber测试的Jenkins测试作业,并希望我的作业始终能够成功直到达到某个阈值(由我控制)。测试失败后,Allure插件始终将我的版本标记为“不稳定”,但我不希望我的版本不稳定。我该如何改变这种行为?

我尝试设置     <testFailureIgnore>true</testFailureIgnore> 在pom.xml中,这可以使Maven Build成功。但是,我正在人工检查prometheusData.txt中生成的Allure结果,并根据该结果来失败/传递构建。

我希望能够根据80%阈值设置成功/失败状态。我现在还没有发现Allure存在任何阈值功能,这就是为什么我不得不这样做

管道脚本

def testsInfo = readFile "${env.WORKSPACE}/allure-report/export/prometheusData.txt"

def passingTests = 0;
def totalTests = 0 
def lineText = ''
def lineNum = 0
while(lineText != 'found'){
    findText = testsInfo.split("\n")[lineNum]
    if(findText.contains('launch_status_passed')){
        passingTests = findText.split(' ')[1].toInteger()
    }
    if(findText.contains('launch_retries_run')){
        totalTests = findText.split(' ')[1].toInteger()
        lineText='found'
    }
    lineNum++
}

echo 'passing tests: ' + passingTests + '    total tests: ' + totalTests
percentSuccess = ((passingTests / totalTests) * 100).toString().split('\\.')[0]
echo 'Percent of tests that passed: ' + percentSuccess


if(build_ok && (percentSuccess.toInteger() > 80)) {
    currentBuild.result = 'SUCCESS'
    echo 'build OK'
} else {
    currentBuild.result = 'FAILURE'
    echo 'build bad'
}

詹金斯输出

[INFO] 
[INFO] Results:
[INFO] 
[ERROR] Failures: 
[ERROR]   expected:<true> but was:<false>
[ERROR]   expected:<[1].00> but was:<[2].00>
[ERROR]   expected:<1.[0]0> but was:<1.[4]0>
[INFO] 
[ERROR] Tests run: 90, Failures: 3, Errors: 0, Skipped: 0
[INFO] 
[ERROR] There are test failures.
[INFO] -----------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] -----------------------------------------------------------------
[INFO] Total time: 04:05 min
[INFO] Finished at: 2019-06-24T17:31:36Z
[INFO] Final Memory: 33M/1349M
[INFO] -----------------------------------------------------------------
Allure report was successfully generated.
Creating artifact for the build.
Artifact was added to the build.
[Pipeline] // stage
[Pipeline] readFile
[Pipeline] echo
passing tests: 96    total tests: 100
[Pipeline] echo
Percent of tests that passed: 96
[Pipeline] }
[Pipeline] // node
[Pipeline] End of Pipeline
Finished: UNSTABLE

0 个答案:

没有答案