简体   繁体   中英

Fail Pipeline in Jenkins

I have used Jenkins to create a CI pipeline for my node js application. My pipeline includes jobs such as build,unit test,integration test,code analysis etc. I was wondering if it is possible to fail a build if for example by implementing threshold like z number of tests failed or pass rate < z% ? I know by default a build will fail if even one test case fails.

Your unit test script will need to handle the math & logic to determine what percent of tests failing is bad enough to fail the whole job. Then your unit test script can return pass (zero) or fail (anything else) and Jenkins will mark the build accordingly.

Here is an example of how to test with mocha in jenkins:

https://johnhamelink.com/2012/11/13/testing-nodejs-with-jenkins

Here is a related question: Why when test fails jenkins still says success?

Try Multijob Plugin

This plugin also helps to run your pipelined jobs

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM