1
0
mirror of https://github.com/SAP/jenkins-library.git synced 2024-12-14 11:03:09 +02:00
sap-jenkins-library/documentation/docs/steps/checksPublishResults.md

138 lines
4.3 KiB
Markdown
Raw Normal View History

2019-03-28 14:27:41 +02:00
# ${docGenStepName}
2018-01-29 17:49:25 +02:00
2019-03-28 14:27:41 +02:00
## ${docGenDescription}
2018-01-29 17:49:25 +02:00
## Prerequisites
2018-01-29 17:49:25 +02:00
* **static check result files** - To use this step, there must be static check result files available.
2018-02-06 22:36:31 +02:00
* installed plugins:
* [pmd](https://plugins.jenkins.io/pmd)
* [dry](https://plugins.jenkins.io/dry)
* [findbugs](https://plugins.jenkins.io/findbugs)
* [checkstyle](https://plugins.jenkins.io/checkstyle)
* [warnings](https://plugins.jenkins.io/warnings)
* [core](https://plugins.jenkins.io/core)
2018-01-29 17:49:25 +02:00
2019-03-28 14:27:41 +02:00
## ${docGenParameters}
2018-01-30 20:42:27 +02:00
### aggregation
2018-01-30 20:42:27 +02:00
| parameter | mandatory | default | possible values |
| ----------|-----------|---------|-----------------|
| thresholds | no | none | see [thresholds](#thresholds) |
### tasks
2018-01-30 20:42:27 +02:00
| parameter | mandatory | default | possible values |
| ----------|-----------|---------|-----------------|
| pattern | no | `'**/*.java'` | |
| archive | no | `true` | `true`, `false` |
| high | no | `'FIXME'` | |
| normal | no | `'TODO,REVISE,XXX'` | |
| low | no | | |
| thresholds | no | none | see [thresholds](#thresholds) |
### pmd
2018-01-30 20:42:27 +02:00
| parameter | mandatory | default | possible values |
| ----------|-----------|---------|-----------------|
| pattern | no | `'**/target/pmd.xml'` | |
| archive | no | `true` | `true`, `false` |
| thresholds | no | none | see [thresholds](#thresholds) |
### cpd
2018-01-30 20:42:27 +02:00
| parameter | mandatory | default | possible values |
| ----------|-----------|---------|-----------------|
| pattern | no | `'**/target/cpd.xml'` | |
| archive | no | `true` | `true`, `false` |
| thresholds | no | none | see [thresholds](#thresholds) |
### findbugs
2018-01-30 20:42:27 +02:00
| parameter | mandatory | default | possible values |
| ----------|-----------|---------|-----------------|
| pattern | no | `'**/target/findbugsXml.xml, **/target/findbugs.xml'` | |
| archive | no | `true` | true, false |
| thresholds | no | none | see [thresholds](#thresholds) |
### checkstyle
2018-01-30 20:42:27 +02:00
| parameter | mandatory | default | possible values |
| ----------|-----------|---------|-----------------|
| pattern | no | `'**/target/checkstyle-result.xml'` | |
| archive | no | `true` | `true`, `false` |
| thresholds | no | none | see [thresholds](#thresholds) |
### eslint
2018-01-30 20:42:27 +02:00
| parameter | mandatory | default | possible values |
| ----------|-----------|---------|-----------------|
| pattern | no | `'**/eslint.jslint.xml'` | |
| archive | no | `true` | `true`, `false` |
| thresholds | no | none | see [thresholds](#thresholds) |
### pylint
2018-01-30 20:42:27 +02:00
| parameter | mandatory | default | possible values |
| ----------|-----------|---------|-----------------|
| pattern | no | `'**/pylint.log'` | |
| archive | no | `true` | `true`, `false` |
| thresholds | no | none | see [thresholds](#thresholds) |
2019-03-28 14:27:41 +02:00
## ${docGenConfiguration}
2018-03-06 14:43:53 +02:00
2018-01-30 20:42:27 +02:00
### Thresholds
It is possible to define thresholds to fail the build on a certain count of findings. To achive this, just define your thresholds a followed for the specific check tool:
```groovy
thresholds: [fail: [all: 999, low: 99, normal: 9, high: 0]]
```
This way, the jenkins will fail the build on 1 high issue, 10 normal issues, 100 low issues or a total issue count of 1000.
The `thresholds` parameter can be set for `aggregation`, `tasks`, `pmd`, `cpd`, `findbugs`, `checkstyle`, `eslint` and `pylint`.
```groovy
2018-02-02 15:50:26 +02:00
checksPublishResults(
2018-01-30 20:42:27 +02:00
tasks: true,
pmd: [pattern: '**/target/pmd-results.xml', thresholds: [fail: [low: 100]]],
cpd: [archive: false],
aggregation: [thresholds: [fail: [high: 0]]],
archive: true
)
```
2018-02-02 15:50:26 +02:00
![StaticChecks Thresholds](../images/StaticChecks_Threshold.png)
2018-01-29 17:49:25 +02:00
## Side effects
2018-02-12 09:41:12 +02:00
If both ESLint and PyLint results are published, they are not correctly aggregated in the aggregator plugin.
2018-01-29 17:49:25 +02:00
## Exceptions
2018-01-30 20:42:27 +02:00
none
2018-01-29 17:49:25 +02:00
## Example
2018-01-29 17:49:25 +02:00
```groovy
// publish java results from pmd, cpd, checkstyle & findbugs
2018-02-02 15:50:26 +02:00
checksPublishResults archive: true, pmd: true, cpd: true, findbugs: true, checkstyle: true, aggregation: [thresholds: [fail: [high: 0]]]
2018-01-29 17:49:25 +02:00
```
```groovy
// publish javascript results from ESLint
2018-02-02 15:50:26 +02:00
checksPublishResults archive: true, eslint: [pattern: '**/result-file-with-fancy-name.xml'], aggregation: [thresholds: [fail: [high: 0, normal: 10]]]
2018-01-29 17:49:25 +02:00
```
```groovy
// publish scala results from scalastyle
2018-02-02 15:50:26 +02:00
checksPublishResults archive: true, checkstyle: [pattern: '**/target/scalastyle-result.xml']
2018-01-29 17:49:25 +02:00
```
```groovy
// publish python results from pylint
2018-02-02 15:50:26 +02:00
checksPublishResults archive: true, pylint: [pattern: '**/target/pylint.log']
2018-01-29 17:49:25 +02:00
```