Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8003633
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T16:41:57+00:00 2026-06-04T16:41:57+00:00

My project has a number of packages (models, controllers, etc.). I’ve set up Jenkins

  • 0

My project has a number of packages (“models”, “controllers”, etc.). I’ve set up Jenkins with the Cobertura plugin to generate coverage reports, which is great. I’d like to mark a build as unstable if coverage drops below a certain threshold, but only on certain packages (e.g., “controllers”, but not “models”). I don’t see an obvious way to do this in the configuration UI, however — it looks like the thresholds are global.

Is there a way to do this?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T16:41:59+00:00Added an answer on June 4, 2026 at 4:41 pm

    (Answering my own question here)

    As far as I can tell, this isn’t possible — I haven’t seen anything after a couple days of looking. I wrote a simple script that would do what I want — take the coverage output, parse it, and fail the build if coverage of specific packages didn’t meet certain thresholds. It’s dirty and can be cleaned up/expanded, but the basic idea is here. Comments are welcome.

    #!/usr/bin/env python
    
    '''
    Jenkins' Cobertura plugin doesn't allow marking a build as successful or
    failed based on coverage of individual packages -- only the project as a
    whole. This script will parse the coverage.xml file and fail if the coverage of
    specified packages doesn't meet the thresholds given
    
    '''
    
    import sys
    
    from lxml import etree
    
    PACKAGES_XPATH = etree.XPath('/coverage/packages/package')
    
    
    def main(argv):
        filename = argv[0]
        package_args = argv[1:] if len(argv) > 1 else []
        # format is package_name:coverage_threshold
        package_coverage = {package: int(coverage) for
            package, coverage in [x.split(':') for x in package_args]}
    
        xml = open(filename, 'r').read()
        root = etree.fromstring(xml)
    
        packages = PACKAGES_XPATH(root)
    
        failed = False
        for package in packages:
            name = package.get('name')
            if name in package_coverage:
                # We care about this one
                print 'Checking package {} -- need {}% coverage'.format(
                    name, package_coverage[name])
                coverage = float(package.get('line-rate', '0.0')) * 100
                if coverage < package_coverage[name]:
                    print ('FAILED - Coverage for package {} is {}% -- '
                           'minimum is {}%'.format(
                            name, coverage, package_coverage[name]))
                    failed = True
                else:
                    print "PASS"
    
        if failed:
            sys.exit(1)
    
    if __name__ == '__main__':
        main(sys.argv[1:])
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have set up cruisecontrol.net cs for my project that has a number of
I have a Reporting services project that has a number of reports in the
I'm developing a project that has a number of hardware sensors connecting to the
I have been handed this project that has a large number of issues with
I've inherited an MVC3 project that has a large number of ASPX views that
I've got a project which has a manifest file (which includes a version number),
I have an object Project which has a number of fields, one of which
My project has a requirement to gather data from a number of sources, then
currently i have a project that has nuget packages that are placed in folders
I am working on a legacy java project which has a number of design

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.