The following plugin provides functionality available through Pipeline-compatible steps. Read more about how to integrate steps into your Pipeline in the Steps section of the Pipeline Syntax page.

For a list of other such plugins, see the Pipeline Steps Reference page.

Code Coverage API Plugin

recordCoverage: Record code coverage results

  • checksAnnotationScope (optional)
    Select the scope of source code annotations in SCM checks. The following different scopes are supported:
    SKIP - Skip annotations
    Do not publish any annotations, just report the coverage report summary.
    MODIFIED_LINES - Publish annotations for modified lines
    Publish only annotations for lines that have been changed (with respect to the reference build). Teams can use these annotations to improve the quality of pull or merge requests.
    ALL_LINES - Publish annotations for all lines
    Publish annotations for existing and new code. There might be a lot of annotations depending on your code coverage.
    • Values: SKIP, MODIFIED_LINES, ALL_LINES
  • checksName : String (optional)
    If provided, and publishing checks enabled, the plugin will use this name when publishing results to corresponding SCM hosting platforms. If not, the default name will be used.
  • enabledForFailure : boolean (optional)
    This toggle determines if recording of code coverage results should be enabled for failed builds as well. By default, code coverage results are only recorded for stable or unstable builds, but not for failed builds: code coverage results might be inaccurate if the build failed.
  • failOnError : boolean (optional)
    This toggle determines if the coverage plugin should fail the build whenever an error occurred during processing of the coverage results. Several errors might occur: file pattern matches no files, source files could not be copied, etc. By default, these errors are logged in a separate view but the build status will not be altered. If you would rather like to fail the build on such errors, please tick this checkbox.
  • id : String (optional)
    You can override the default ID (i.e., URL) that is used to publish the coverage results in this job. This ID is used as link to the results, so choose a short and meaningful name. Allowed elements are characters, digits, dashes and underscores (more precisely, the ID must match the regular expression \p{Alnum}[\p{Alnum}-_]*). The chosen ID must be unique in a job, i.e., it must not be already used by other results. If you leave the ID field empty, then the built-in default ID "coverage" will be used to show the results.
  • name : String (optional)
    You can override the display name of the coverage results. This name is used in details views, trend captions, hyperlinks, and checks titles. If you leave the name field empty, then the built-in default name "Coverage Results" will be used.
  • qualityGates (optional)
    Add one or more quality gates that will be checked right after the build. You can define for each quality gate which metric and baseline will be used to select the value that will be compared with the threshold.
      Array / List of Nested Object
    • threshold : double
      The threshold defines the minimum or maximum value (depends on the metric) of a coverage metric that is required to pass or miss the quality gate.
    • metric
      Select the metric that should be evaluated for this quality gate. The following different metrics are supported:
      MODULE
      Covered and missed modules (given as percentage)
      PACKAGE
      Covered and missed packages - also used for namespaces or directories (given as percentage)
      FILE
      Covered and missed files (given as percentage)
      CLASS
      Covered and missed classes (given as percentage)
      METHOD
      Covered and missed methods (given as percentage)
      LINE
      Line coverage (given as percentage)
      INSTRUCTION
      Instruction coverage (given as percentage)
      BRANCH
      Branch coverage or decision coverage (given as percentage)
      MUTATION
      Mutation coverage (given as percentage)
      COMPLEXITY
      Cyclomatic complexity (given as absolute number)
      COMPLEXITY_DENSITY
      Cyclomatic complexity density (given as relation between cyclomatic complexity and lines of code)
      LOC
      Lines of code (given as absolute number)
      • Values: CONTAINER, MODULE, PACKAGE, FILE, CLASS, METHOD, LINE, BRANCH, INSTRUCTION, MUTATION, COMPLEXITY, COMPLEXITY_DENSITY, LOC
    • baseline (optional)
      Select the baseline to be used for the code coverage computation of this quality gate. The following different baselines are supported:
      Overall project - PROJECT
      Coverage of the whole project. This is an absolute value that might not change much from build to build.
      Overall project (difference to reference job) - PROJECT_DELTA
      Difference between the project coverages of the current build and the reference build. Teams can use this delta value to ensure that the coverage will not decrease.
      Modified code lines - MODIFIED_LINES
      Coverage of the modified lines (e.g., within the modified lines of a pull or merge request) will focus on new or modified code only.
      Modified code lines (difference to overall project) - MODIFIED_LINES_DELTA
      Difference between the project coverage and the modified lines coverage of the current build. Teams can use this delta value to ensure that the coverage of pull requests is better than the whole project coverage.
      Modified files - MODIFIED_FILES
      Coverage of the modified files (e.g., within the files that have been touched in a pull or merge request) will focus on new or modified code only.
      Modified files (difference to overall project) - MODIFIED_FILES_DELTA
      Difference between the project coverage and the modified files coverage of the current build. Teams can use this delta value to ensure that the coverage of pull requests is better than the whole project coverage.
      • Values: PROJECT, PROJECT_DELTA, MODIFIED_LINES, MODIFIED_LINES_DELTA, MODIFIED_FILES, MODIFIED_FILES_DELTA, INDIRECT
    • criticality (optional)
      When a quality gate has been missed, this property determines whether the result of the associated coverage stage will be marked as unstable or failure. The following two enum values are possible:
      UNSTABLE
      Set the build status to unstable if the quality gate has been missed.
      FAILURE
      Fail the build if the quality gate has been missed.
      • Values: UNSTABLE, FAILURE
  • scm : String (optional)
    Specify the key of your repository (substring is sufficient) if you are using multiple SCMs in your job. When your job is composed of several SCM checkouts (modules, pipeline libraries, etc.) then Jenkins stores all those repositories in an unsorted way.
  • skipPublishingChecks : boolean (optional)
    If this option is unchecked, then the plugin automatically publishes a summary of the coverage report to corresponding SCM hosting platforms. For example, if you are using this feature for a GitHub organization project, the coverage summary will be published to GitHub through the Checks API. If this operation slows down your build, or you don't want to publish the summary to SCM platforms, you can use this option to deactivate this feature.
  • skipSymbolicLinks : boolean (optional)
    The coverage plugin will not traverse symbolic links while scanning for report or source code files when this option is enabled.
  • sourceCodeEncoding : String (optional)
    In order to correctly show all your covered source code files in the detail views, the plugin must open these files with the correct character encoding (UTF-8, ISO-8859-1, etc.). If you leave this field empty then the default encoding of the platform will be used. This might work but is not recommended.
  • sourceCodeRetention (optional)
    Select the strategy that should be used to store the colored source code files. Storing the affected source code files along with the coverage information (which lines have been covered, which not) consumes a lot of space on your hard disk for large projects. So if your server has not enough free space available to store the sources for all builds it might make more sense to store only the coverage results of the last build. In this case, the plugin will automatically discard old results before the new sources will be stored. If you do not need the source files at all you can deactivate the storing of source code files. The following options are supported:
    NEVER
    Never store source code files.
    LAST_BUILD
    Store source code files of the last build, delete older artifacts.
    EVERY_BUILD
    Store source code files for all builds, never delete those files automatically.
    • Values: NEVER, LAST_BUILD, EVERY_BUILD, MODIFIED
  • sourceDirectories (optional)
    Select additional folders that contain the source code files of the job. Since the plugin also reads the affected source code files it needs to copy these files from the agent to the controller. If these files are not part of the workspace (or checked out into a sub folder of the workspace) they are not automatically found. So you can add one or more source code directories where the plugin tries to find these files. Note, that due to security restrictions additional paths outside the workspace need to be registered in Jenkins system configuration before they can be used here.
      Array / List of Nested Object
    • path : String
      Select the path to your source code files. This plugin copies source code files to Jenkins' build folder so that these files can be rendered in the user interface together with the plugin results. If these files are referenced with relative paths then they cannot be found by the plugin. In these cases you need to specify one or more relative paths within the workspace where the plugin can locate them. Alternatively, you can also specify absolute paths if the source code files are stored outside the workspace (in a directory on the agent). All absolute paths must be additionally approved by an administrator in Jenkins' global configuration page.
  • tools (optional)
    Select one of the supported coverage report formats. Most coverage tools support the output to the Cobertura format, please look into the manual of your coverage tool to see if that format is supported.
      Array / List of Nested Object
    • parser (optional)
      Select the ID of the parser that should read and parse your report files - currently, parsers for Cobertura (id = COBERTURA), JaCoCo (id = JACOCO), and PIT (id = PIT) are supported.
      • Values: COBERTURA, JACOCO, PIT
    • pattern : String (optional)
      A pattern is defined by an Ant Fileset ''includes'' setting that specifies the coverage report files to read. Multiple patterns can be separated by space or comma. Note that such a pattern is resolved in Jenkins' workspace, so the paths must be relative only. If no pattern is specified then the default pattern of the coverage tool will be used.

publishCoverage: Publish Coverage Report [deprecated]

  • adapters (optional)
      Array / List of Nested Choice of Objects
    • antPath
      • path : String
    • dListingAdapter
      • path : String
      • mergeToOneReport : boolean (optional)
      • thresholds (optional)
          Array / List of Nested Object
        • thresholdTarget : String
        • failUnhealthy : boolean (optional)
        • unhealthyThreshold : float (optional)
        • unstableThreshold : float (optional)
    • istanbulCoberturaAdapter
      • path : String
      • mergeToOneReport : boolean (optional)
      • thresholds (optional)
          Array / List of Nested Object
        • thresholdTarget : String
        • failUnhealthy : boolean (optional)
        • unhealthyThreshold : float (optional)
        • unstableThreshold : float (optional)
    • jacocoAdapter
      • path : String
      • mergeToOneReport : boolean (optional)
      • thresholds (optional)
          Array / List of Nested Object
        • thresholdTarget : String
        • failUnhealthy : boolean (optional)
        • unhealthyThreshold : float (optional)
        • unstableThreshold : float (optional)
    • llvmAdapter
      • path : String
      • mergeToOneReport : boolean (optional)
      • thresholds (optional)
          Array / List of Nested Object
        • thresholdTarget : String
        • failUnhealthy : boolean (optional)
        • unhealthyThreshold : float (optional)
        • unstableThreshold : float (optional)
    • opencoverAdapter
      • path : String
      • mergeToOneReport : boolean (optional)
      • thresholds (optional)
          Array / List of Nested Object
        • thresholdTarget : String
        • failUnhealthy : boolean (optional)
        • unhealthyThreshold : float (optional)
        • unstableThreshold : float (optional)
    • sonarGenericCoverageAdapter
      • path : String
      • mergeToOneReport : boolean (optional)
      • thresholds (optional)
          Array / List of Nested Object
        • thresholdTarget : String
        • failUnhealthy : boolean (optional)
        • unhealthyThreshold : float (optional)
        • unstableThreshold : float (optional)
    • coberturaAdapter
      • path : String
      • mergeToOneReport : boolean (optional)
      • thresholds (optional)
          Array / List of Nested Object
        • thresholdTarget : String
        • failUnhealthy : boolean (optional)
        • unhealthyThreshold : float (optional)
        • unstableThreshold : float (optional)
    • cobertura
      • path : String
      • mergeToOneReport : boolean (optional)
      • thresholds (optional)
          Array / List of Nested Object
        • thresholdTarget : String
        • failUnhealthy : boolean (optional)
        • unhealthyThreshold : float (optional)
        • unstableThreshold : float (optional)
  • applyThresholdRecursively : boolean (optional)
    By default, this plugins will only apply threshold at report level. If this option is set to true, it will apply threshold to all levels. For example, if this option is true, and if you have specified a `Line` threshold, this plugin will check all modules, directories, files...
  • calculateDiffForChangeRequests : boolean (optional)
    If it is a change request build, calculate code coverage diff with a target branch build
  • checksName : String (optional)
    If provided, and publishing checks enabled, the plugin will use this name when publishing results to corresponding SCM hosting platforms. If not, the default of "Code Coverage" will be used.
  • failBuildIfCoverageDecreasedInChangeRequest : boolean (optional)
    Fail the build in case if code coverage decreased in comparison with the target branch
  • failNoReports : boolean (optional)
    Fail the build if no coverage reports found.
  • failUnhealthy : boolean (optional)
    Fail the build if coverage is lower than healthy threshold.
  • failUnstable : boolean (optional)
    Fail the build if coverage is lower than stable threshold.
  • globalThresholds (optional)
      Array / List of Nested Object
    • thresholdTarget : String
    • failUnhealthy : boolean (optional)
    • unhealthyThreshold : float (optional)
    • unstableThreshold : float (optional)
  • scm : String (optional)
  • skipPublishingChecks : boolean (optional)
    If unchecked, the plugin will automatically publish the coverage to corresponding SCM platforms. For example, if you are using this feature for a GitHub organization project, the coverage will be published to GitHub through the Checks API.
  • sourceCodeEncoding : String (optional)
    In order to correctly show all your affected source code files in the detail views, the plugin must open these files with the correct character encoding (UTF-8, ISO-8859-1, etc.). If you leave this field empty then the default encoding of the platform will be used. This might work but is not recommended.
  • sourceDirectories (optional)
    Since the plugin also reads the affected source code files it needs to copy these files from the agent to the controller. If these files are not part of the workspace (or checked out into a sub folder of the workspace) they are not automatically found. So you can add one or more source code directories where the plugin tries to find these files. Note, that due to security restrictions additional paths outside the workspace need to be registered in Jenkins system configuration before they can be used here.
      Array / List of Nested Object
    • path : String
      Select the path to your source code files. This plugin copies source code files to Jenkins' build folder so that these files can be rendered in the user interface together with the plugin results. If these files are referenced with relative paths then they cannot be found by the plugin. In these cases you need to specify one or more relative paths within the workspace where the plugin can locate them. Alternatively, you can also specify absolute paths if the source code files are stored outside the workspace (in a directory on the agent). All absolute paths must be additionally approved by an administrator in Jenkins' global configuration page.
  • sourceFileResolver (optional)
      Nested Object
    • level
      • Values: NEVER_STORE, STORE_LAST_BUILD, STORE_ALL_BUILD
  • tag : String (optional)

Was this page helpful?

Please submit your feedback about this page through this quick form.

Alternatively, if you don't wish to complete the quick form, you can simply indicate if you found this page helpful?

    


See existing feedback here.