0

We are using springboot, Jacoco, and azure devops, we need to break the pipeline if the percentage of code coverage is less than 70%, how can I achieve this with azure pipeline. Kindly suggest.

Abhijit Sarkar
  • 21,927
  • 20
  • 110
  • 219

1 Answers1

2

Based on your requirement, you can use the Build Quality Checks task from Build Quality Checks extension.

It sets the threshold for code coverage and then compares the actual values to determine if it passes.

Since you are using Springboot, you need to add the task: Publish code coverage results task before the Build Quality Checks task.

For example:

steps:
- task: Test task

- task: PublishCodeCoverageResults@1
  displayName: 'Publish code coverage'
  inputs:
    codeCoverageTool: Jacoco
    summaryFileLocation: 'coverage.xml'

- task: BuildQualityChecks@8
  displayName: 'Check build quality'
  inputs:
    checkCoverage: true
    coverageFailOption: fixed
    coverageThreshold: 70

Here is the doc about Build Quality Checks task

If you are using a test tool other then MSTest (i.e., anything other than the Visual Studio Test task), please use the Publish Code Coverage Results task to publish your coverage data before you add the policy.

Kevin Lu-MSFT
  • 20,786
  • 3
  • 19
  • 28