我在我的jenkins shell命令中添加了执行命令:
cd apitests && ./gradlew cucumber -Pthreads=${THREADS} -Ptags="not @notReady" && [ -s rerun/failed_scenarios.txt ] && ./gradlew cucumber -PfeaturePath='@rerun/failed_scenarios.txt' -Pthreads=80 || echo "File empty"
在gradle中,我添加了带有 cucumber 选项的任务,我将其设置为将失败的测试保存到文件:
cucumber {
threads = 50
glue = 'classpath:com.sixtleasing.cucumber.steps'
plugin = ["pretty", "html:target/zucchini", "json:target/zucchini.json", "rerun:rerun/failed_scenarios.txt"]
(...)
}
所有测试均为绿色时,一切正常。当其中一项测试失败时,问题开始。在这种情况下,我会在控制台中看到:
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':cucumber'.
> java.lang.RuntimeException: The execution failed
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
BUILD FAILED
为什么?如果我分开运行命令可以正常工作,但在 Jenkins 中作为一个shell命令则不会
最佳答案
如果第一次用 cucumber 调用gradle失败,那么&&
右边的任何内容都不会执行。这是因为如果构建失败,则gradlew进程的返回代码将为非零。
试试看:
cd apitests && ./gradlew cucumber -Pthreads=${THREADS} -Ptags="not @notReady" || ( [ -s rerun/failed_scenarios.txt ] && ./gradlew cucumber -PfeaturePath='@rerun/failed_scenarios.txt' -Pthreads=80 || echo "File empty" )
关于jenkins - cucumber 4 jvm使用shell命令在jenkins中重新运行失败的测试,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56363939/