Awesome
Violation Comments to GitHub Jenkins Plugin
Archived, see motivation here https://github.com/tomasbjerre/violation-comments-to-github-lib
This is a Jenkins plugin for Violation Comments to GitHub Lib. This plugin will find report files from static code analysis and comment GitHub pull requests with the content.
You can have a look at violations-test to see what the result may look like.
It uses Violation Comments to GitHub Server Lib and supports the same formats as Violations Lib.
It supports:
- AndoidLint
- Checkstyle
- CPPLint
- CPPCheck
- CSSLint
- Findbugs
- Flake8 (PyLint, Pep8, Mccabe, PyFlakes)
- JSHint
- Lint A common XML format, used by different linters.
- PerlCritic
- PMD
- ReSharper
- XMLLint
There is also:
- A Gradle plugin.
- A Maven plugin.
Available in Jenkins here.
You will need to the pull request id for the pull request that was built. You may want to have a look at GitHub Pull Request Builder Plugin, it provides the environment variable ghprbPullId
.
Screenshots
When installed, a post build action will be available.
The pull request will be commented like this.
Job DSL Plugin
This plugin can be used with the Job DSL Plugin.
job('example') {
publishers {
violationsToGitHubRecorder {
config {
gitHubUrl("https://api.github.com/")
repositoryOwner("tomasbjerre")
repositoryName("violations-test")
pullRequestId("2")
useOAuth2Token(false)
oAuth2Token("")
useUsernamePasswordCredentials(false)
usernamePasswordCredentialsId("")
useUsernamePassword(true)
username("")
password("")
createSingleFileComments(true)
createCommentWithAllSingleFileComments(true)
commentOnlyChangedContent(true)
violationConfigs {
violationConfig {
reporter("FINDBUGS")
pattern(".*/findbugs/.*\\.xml\$")
}
}
}
}
}
}
Pipeline Plugin
This plugin can be used with the Pipeline Plugin:
node {
checkout([
$class: 'GitSCM',
branches: [[ name: '*/master' ]],
doGenerateSubmoduleConfigurations: false,
extensions: [],
submoduleCfg: [],
userRemoteConfigs: [[ url: 'https://github.com/tomasbjerre/violations-test.git' ]]
])
sh '''
./gradlew build
'''
step([
$class: 'ViolationsToGitHubRecorder',
config: [
gitHubUrl: 'https://api.github.com/',
repositoryOwner: 'tomasbjerre',
repositoryName: 'violations-test',
pullRequestId: '2',
useOAuth2Token: false,
oAuth2Token: '',
useUsernamePassword: true,
username: 'admin',
password: 'admin',
useUsernamePasswordCredentials: false,
usernamePasswordCredentialsId: '',
createCommentWithAllSingleFileComments: true,
createSingleFileComments: true,
commentOnlyChangedContent: true,
violationConfigs: [
[ pattern: '.*/checkstyle/.*\\.xml$', reporter: 'CHECKSTYLE' ],
[ pattern: '.*/findbugs/.*\\.xml$', reporter: 'FINDBUGS' ],
]
]
])
}
Plugin development
More details on Jenkins plugin development is available here.
There is a /build.sh
that will perform a full build and test the plugin. You may have a look at sandbox/settings.xml on how to configure your Maven settings.
A release is created like this. You need to clone from jenkinsci-repo, with https and have username/password in settings.xml.
mvn release:prepare release:perform