Embold allows users to enforce minimum code coverage thresholds for newly added or modified code using quality gates. While Embold does not generate coverage reports itself, it supports integration with third-party tools such as JaCoCo. Users can define custom quality gate profiles with a specified new code coverage percentage, assign them to specific repositories, and trigger remote scans using the -nc
(new code) flag. The scan compares code changes between commits and overlays coverage data to determine compliance. Results are then visualized in the Embold UI under the Quality Gate section, helping teams maintain test coverage standards for new code.
Note: The overall quality gate is also applied alongside the new code quality gate. If the overall quality gate fails, the quality gate result will be marked as failed. If user want only the new code coverage to be considered in the quality gate evaluation, please leave the other thresholds empty in the quality gate profile.
Prerequisites
- Coverage Report Tool (e.g., JaCoCo)
A supported code coverage tool like JaCoCo must be set up to generate coverage reports. - Version Control System (e.g., Git)
A version control system is required to track code changes between commits or branches to identify newly added or modified lines, currently it is only supported for git. - The user should run the Embold scan on the same host where the project was built and the coverage data was generated.
- The coverage reports should be in XML format.
- This feature is only supported in remote scans.
Steps to Configure and Use New Code Coverage Quality Gate
- Navigate to Admin Panel on the bottom left corner.
- Click on Quality Gate Profile from the side menu.
- Define New Code Coverage Threshold.
In the New Code section, specify the minimum coverage percentage required for newly added or modified code. Click Save.
Note : The overall quality gate is also applied alongside the new code quality gate. If the overall quality gate fails, the quality gate result will be marked as failed. If you want only the new code coverage to be considered in the quality gate evaluation, please leave the other thresholds empty in the quality gate profile. - Assign the New Quality Gate to a Repository
Navigate to the repository where you want to apply this quality gate profile and click on the three-dot menu next to the repository name and selectQuality Gate Profile
- Choose Quality Gate Profile from the dropdown and select the newly created quality gate profile and click Save.
- Run a Remote Scan with New Code Coverage Flag
- Execute a remote scan using the
-nc
(new code) flag with one of the supported coverage tools: - Command Syntax:
embold-scanner analyse -c <./repository configuration.json> -u <Embold URL> -t <Embold TOKEN> -b <BASE_DIR> -d <DATA_DIR> -s <snapshot name> -r <REPO UID> -sh <CORONA PACKAGE PATH> -l <LOG_FOLDER> -nc <new code> -sc<starting commit> - Example:
./embold-scanner analyse -c /Users/user/repository-configuration.json -u http://localhost:3000 -t
<token>-b /Users/user/github/jacoco-new-code-example/ -d /Users/user/github/dataDir -nc -sc 09ad1f9ee0e5c0d6c65da9ee5b41838edbc65608
-nc
: Enables evaluation of new code coverage.-sc
: (Optional) Defines the starting commit. Coverage will be measured for code changed between<starting_commit>
and the current HEAD.
- Execute a remote scan using the
- Note: If the
-sc
option is not provided, the tool defaults to comparingHEAD
withHEAD~1
.
Ensure that the provided starting commit exists in the current branch being built. - User can view the New Code Coverage results directly in the Quality Gate section of the Embold UI after the scan is complete.