jenkinsci / violation-comments-to-gitlab-plugin

Comments GitLab merge requests with static code analyzer findings.
https://plugins.jenkins.io/violation-comments-to-gitlab
MIT License
20 stars 4 forks source link

Let report log level to be configured per violationConfig #18

Open WonderCsabo opened 5 years ago

WonderCsabo commented 5 years ago

Currently the minSeverity can be only set globally. It would be nice to configure it per violationConfig, since some kind of reports can be more important than others. For example i am interested in all Checkstyle violations, but only interested in error Android LINT violations. We cannot configure the plugin this way currently.

The syntax could be:

violationConfigs: [
  [ pattern: '.*/checkstyle/.*\\.xml$', parser: 'CHECKSTYLE', reporter: 'Checkstyle', minSeverity: 'ERROR'],
  [ pattern: '.*/reports/lint-results.*\\.xml$', parser: 'ANDROIDLINT', reporter: 'AndroidLint', minSeverity: 'WARN']
]
tomasbjerre commented 5 years ago

Run the plugin twice to achieve this:

step([
 $class: 'ViolationsToGitLabRecorder',
 config: [
 ...
 minSeverity: 'WARN',
 ...
 violationConfigs: [
  [ pattern: '.*/reports/lint-results.*\\.xml$', parser: 'ANDROIDLINT', reporter: 'AndroidLint', minSeverity: 'WARN']
 ]
])

step([
 $class: 'ViolationsToGitLabRecorder',
 config: [
 ...
 minSeverity: 'ERROR',
 ...
 violationConfigs: [
  [ pattern: '.*/checkstyle/.*\\.xml$', parser: 'CHECKSTYLE', reporter: 'Checkstyle', minSeverity: 'ERROR']
 ]
])
tomasbjerre commented 5 years ago

And a heads up on keepOldComments attribute. Having it set to false in the second step above will make that step remove comments from the first step above. So set it to true in the second step.