1
我想使用聚合物-cli将我们的聚合物测试构建过程整合到Jenkins CI/CD管道中。我想自动执行这些步骤来构建我们的Web组件测试用例。目前,我正在通过在终端上执行“聚合物测试”手动执行此操作。我还希望自动化过程提供指示失败测试用例的报告。如果您在CI/CD管道中实施了此步骤,请提供步骤。将聚合物测试构建过程集成到Jenkins CI/CD管道中
我想使用聚合物-cli将我们的聚合物测试构建过程整合到Jenkins CI/CD管道中。我想自动执行这些步骤来构建我们的Web组件测试用例。目前,我正在通过在终端上执行“聚合物测试”手动执行此操作。我还希望自动化过程提供指示失败测试用例的报告。如果您在CI/CD管道中实施了此步骤,请提供步骤。将聚合物测试构建过程集成到Jenkins CI/CD管道中
我们有以下工作设置这种情况下,使用Jenkins2管道:
node{
....
stage('build'){
testresult = bat returnStatus: true, script: 'polymer test --plugin xunit-reporter -l chrome'
step([$class: 'XUnitBuilder', testTimeMargin: '3000', thresholdMode: 1, thresholds: [[$class: 'FailedThreshold', failureNewThreshold: '5', failureThreshold: '10', unstableNewThreshold: '2', unstableThreshold: '5'], [$class: 'SkippedThreshold', failureNewThreshold: '', failureThreshold: '', unstableNewThreshold: '', unstableThreshold: '']], tools: [[$class: 'XUnitDotNetTestType', deleteOutputFiles: true, failIfNotNew: true, pattern: 'TEST-wct.xml', skipNoTestFiles: false, stopProcessingIfError: true]]])
if (testresult != 0) {
currentBuild.result = "UNSTABLE"
echo "ALERT: Some Unittests failed, see log above."
}
}
....
}
的TestResult中由WCT-插件https://github.com/garcus/wct-xunit-reporter为 “/TEST-wct.xml” 写的。 XUnit Builder步骤是这样配置的,即它选择该文件并创建testresult页面。你可以在Jenkins Pipeline语法帮助页面查找它的语法。
又见How to display the XUnit test output on Jenkins 和JUnit formatted test output