Skip to content
This repository was archived by the owner on Nov 19, 2024. It is now read-only.

Commit c79c8de

Browse files
authored
Merge pull request #627 from jenkinsci/relative-paths
Use relative paths when accessing file nodes
2 parents fd35dab + 3fd4d09 commit c79c8de

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+533
-206
lines changed

README.md

Lines changed: 43 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
[![Codecov](https://codecov.io/gh/jenkinsci/code-coverage-api/branch/master/graph/badge.svg)](https://codecov.io/gh/jenkinsci/code-coverage-api-plugin/branch/master)
88
[![CodeQL](https://github.com/jenkinsci/code-coverage-api/workflows/CodeQL/badge.svg?branch=master)](https://github.com/jenkinsci/code-coverage-api/actions/workflows/codeql.yml)
99

10-
The Jenkins code coverage plug-in collects reports of code coverage or mutation coverage tools. It has support for the following report formats:
10+
The Jenkins Code Coverage Plug-in collects reports of code coverage or mutation coverage tools. It has support for the following report formats:
1111

1212
- [JaCoCo](https://www.jacoco.org/jacoco)
1313
- [Cobertura](https://cobertura.github.io/cobertura/)
@@ -25,46 +25,66 @@ This project was part of [GSoC 2018](https://jenkins.io/projects/gsoc/2018/code-
2525

2626
## Features
2727

28-
The code coverage plug-in provides the following features when added as a post build action (or step)
29-
to a job:
28+
The code coverage plug-in provides the following features when added as a post build action (or step) to a job:
3029

31-
* **Coverage analysis of projects and pull requests:**
32-
* all project code (Project Coverage)
33-
* code changes (Modified Lines or Files Coverage)
34-
* coverage changes created by changed test cases (Indirect Coverage Changes)
35-
* **Modernized coverage report visualization:**
36-
* Coverage overview and trend
30+
* Coverage analysis of projects and pull requests: The plugin now computes and shows the absolute coverage of the project, the coverage of the modified files and the coverage of the modified lines, so you can see how the changes actually affect the code coverage. Additionally, the delta of these coverages with respect to the reference build are computed and the coverage changes created by changed test cases (indirect coverage changes).
3731

38-
![alt text](./images/reportOverview_screen.PNG "Coverage overview and trend")
32+
![Coverage overview and trend](./images/summary.png)
33+
34+
* Coverage overview and trend:
35+
36+
![Coverage overview and trend](./images/reportOverview_screen.PNG)
3937

40-
* Colored project coverage tree map for line and branch coverage
38+
* Colored project coverage tree map for line, branch, instruction and mutation coverage:
4139

42-
![alt text](./images/reportTree_screen.PNG "Colored project coverage tree map")
40+
![Colored project coverage tree map](./images/reportTree_screen.PNG)
4341

44-
* Source code navigation
42+
* Source code navigation with a configuration option to store the source code files for all builds, for current build only, or for changed files only:
4543

46-
![alt text](./images/reportFile_screen.PNG "Source code navigation")
44+
![Source code navigation](./images/reportFile_screen.PNG)
4745

48-
* Specific source code view for specifically analyzing the coverage of code changes (Change Coverage):
46+
* Specific source code view for analyzing the coverage of changed code lines:
4947

50-
![alt text](./images/reportCC_screen.PNG "Specific source code view for Change Coverage")
48+
![Specific source code view for Change Coverage](./images/reportCC_screen.PNG)
5149

52-
* Specific source code view for specifically analyzing the coverage after test changes (Indirect Coverage Changes):
50+
* Specific source code view for analyzing the coverage changes that are a result of test changes (indirect coverage changes):
5351

54-
![alt text](./images/reportICC_screen.PNG "Specific source code view for Indirect Coverage Changes")
52+
![Specific source code view for Indirect Coverage Changes](./images/reportICC_screen.PNG)
53+
54+
* Customizable coverage overview for the Jenkins dashboard view and for build results:
5555

56-
* **Customizable coverage overview for the Jenkins dashboard view and for build results:**
5756
![alt text](./images/dashboard_screen.PNG "Analysis overview for Jenkins dashboard")
58-
![alt text](./images/buildview_screen.PNG "Analysis overview for Jenkins build result")
57+
58+
* Quality Gates: You can specify an arbitrary number of quality gates that allow to set the build to unstable or failed if the thresholds are not met. For each quality gate the metric (branch coverage, complexity, etc.) and the baseline (whole project, changed files, etc.) can be defined.
59+
60+
![Quality Gates](./images/quality-gates.png)
61+
62+
* Cyclomatic Complexity and LOC metrics: Several coverage parsers support the measurement of cyclomatic complexity and lines of code. These metrics are now computed and recorded as well:
63+
64+
![Cyclomatic Complexity and LOC metrics](./images/all-metrics.png)
65+
66+
* The recorder has been extended with a native step that is capable of setting the step status (unstable, failed, ok):
67+
68+
![Native step](./images/step.png)
69+
70+
* GitHub checks report to show the detailed line and branch coverage results for pull request:
71+
72+
![Code Coverage Checks Overview](./images/jacoco-coverage-checks.png)
73+
![Code Coverage Checks Annotations](./images/jacoco-coverage-checks-annotations.png)
74+
75+
* GitHub checks report to show the detailed line and mutation coverage results for pull request:
76+
77+
![Mutation Coverage Checks Overview](./images/pit-coverage-checks.png)
78+
![Mutation Coverage Checks Annotations](./images/pit-coverage-checks-annotations.png)
79+
5980

6081
## Usage
6182

62-
:exclamation: The plugin does not run the code coverage, it just visualizes the results reported by such tools.
63-
You still need to enable and configure the code coverage tool in your build file or Jenkinsfile.
83+
:exclamation: The plugin does not run the code coverage, it just visualizes the results reported by such tools. You still need to enable and configure the code coverage tool in your build file or Jenkinsfile. :exclamation:
6484

6585
### Supported project types
6686

67-
The Warnings Next Generation plugin supports the following Jenkins project types:
87+
The Code Coverage Plug-in supports the following Jenkins project types:
6888

6989
- Freestyle Project
7090
- Maven Project

etc/Jenkinsfile.analysis

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
node('java-agent') {
2+
stage ('Checkout') {
3+
checkout scm
4+
}
5+
6+
stage ('Git mining') {
7+
discoverGitReferenceBuild()
8+
mineRepository()
9+
gitDiffStat()
10+
}
11+
12+
stage ('Build, Test, and Static Analysis') {
13+
withMaven(mavenLocalRepo: '/var/data/m2repository', mavenOpts: '-Xmx768m -Xms512m') {
14+
sh 'mvn -V -e clean verify -Dmaven.test.failure.ignore -Dgpg.skip'
15+
}
16+
17+
recordIssues tools: [java(), javaDoc()], aggregatingResults: 'true', id: 'java', name: 'Java', filters:[excludeFile('.*Assert.java')]
18+
recordIssues tool: errorProne(), healthy: 1, unhealthy: 20
19+
20+
junit testResults: '**/target/*-reports/TEST-*.xml'
21+
recordCoverage tools: [[parser: 'JACOCO', pattern: '**/jacoco/jacoco.xml']], sourceCodeRetention: 'EVERY_BUILD',
22+
qualityGates: [ [threshold: 90.0, metric: 'LINE', baseline: 'PROJECT', criticality: 'UNSTABLE']],
23+
sourceDirectories: [[path: 'plugin/src/main/java']]
24+
recordIssues tools: [checkStyle(pattern: 'target/checkstyle-result.xml'),
25+
spotBugs(pattern: 'target/spotbugsXml.xml'),
26+
pmdParser(pattern: 'target/pmd.xml'),
27+
cpd(pattern: 'target/cpd.xml'),
28+
revApi(pattern: 'target/revapi-result.json'),
29+
taskScanner(highTags:'FIXME', normalTags:'TODO', includePattern: '**/*.java', excludePattern: 'target/**/*')]
30+
}
31+
32+
stage ('Collect Maven Warnings') {
33+
recordIssues tool: mavenConsole()
34+
}
35+
}

images/all-metrics.png

73 KB
Loading

images/buildview_screen.PNG

-10.2 KB
Binary file not shown.

images/config-add-adapter.png

-21.3 KB
Binary file not shown.

images/config.png

-68.4 KB
Binary file not shown.
45.6 KB
Loading

images/jacoco-coverage-checks.png

119 KB
Loading
42.9 KB
Loading

images/pit-coverage-checks.png

109 KB
Loading

0 commit comments

Comments
 (0)