Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Failing a Bitbucket Pipeline build when Coverage.py returns a low coverage %

Louis Willcock January 9, 2018

Hey, I have been tasked with kitting out our Pipeline with the ability to fail a build/PR when test coverage is underneath a specific quota. I have read one of your articles which states this as a recommended practice (https://www.atlassian.com/continuous-delivery/introduction-to-code-coverage) but can't actually find any information on how to do it, would appreciate some understanding on this all.

Thanks.

3 answers

0 votes
Mina Luke August 6, 2018 edited

@Louis Willcock @Mathew Morrison
It took me while but it is now working for NodeJS project. Here is what you need to do:

  1. Use NYC https://github.com/istanbuljs/nyc
  2. prefix your mocha test runner with nyc in package.json file as follow: 
    "test": "nyc mocha"
  3. Set your preferred coverage ratio as an environment variable NYC_CHECK_COVERAGE in the repository settings
  4. run NYC check coverage command in pipelines: 
    nyc check-coverage --lines ${NYC_CHECK_COVERAGE}

After doing this when ever you create a PR that has coverage less than the value set in the environment variable will fail pipelines.
Cheers.

0 votes
Mathew Morrison
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
July 25, 2018

Why has nobody answered this from Atlassian?

I too would like some clarity on this, is there documentation somewhere? Surely someone would have had an experience with this they can share, some tips or a pointer in the right direction.

0 votes
Louis Willcock January 10, 2018

I'd really appreciate an answer on how I can fail my builds if coverage is under certain thresholds. I'm still looking for a way to do this.

Suggest an answer

Log in or Sign up to answer
TAGS
atlassian, jira product discovery learning path, product discovery training, idea prioritization, align stakeholders, discovery to delivery, product collaboration, atlassian learning, dev process, roadmap planning, insight capture, team alignment

Elevate Your Skills with Jira Product Discovery!

Unlock your potential and learn how to use Jira Product Discovery to your advantage. You’ll have the expertise to revolutionize ideas and insights, roadmapping, engage and align teams and stakeholders, and deliver the best solutions—faster. Enroll today!

Start Learning
AUG Leaders

Atlassian Community Events