Skip to content
A library for commenting GitHub with violations from static code analyzer reports.
Java Shell
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
gradle/wrapper
src
.gitignore
.travis.yml
CHANGELOG.md
LICENSE
README.md
build.gradle
build.sh
gradle.properties
gradlew
gradlew.bat
release.sh

README.md

Violation Comments to GitHub Lib Build Status Maven Central Bintray

This is a library that adds violation comments from static code analysis to GitHub.

It uses Violation Comments Lib and supports the same formats as Violations Lib.

Very easy to use with a nice builder pattern

  violationsToGitHubApi() //
    .withViolations(".*/findbugs/.*\\.xml$", FINDBUGS, rootFolder) //
    .withViolations(".*/checkstyle/.*\\.xml$", CHECKSTYLE, rootFolder) //
    .withUsername("username") // This is Optional!
    .withPassword("password") // This is Optional!
    .usingOAuth2Token("token") // This is Optional!
    .withRepositoryOwner("repositoryOwner")
    .withRepositoryName("repositoryName")
    .withPullRequestId("pullRequestId")
    .toPullRequest();

Authentication can be done by supplying username/password or OAuth2Token in the builder.

Usage

This software can be used:

You may also checkout this blog post that explains how to set it up with Travis.

Travis

To set this up in Travis, you will need to create a GitHub OAuth2 token.

curl -u 'yourgithubuser' -d '{"note":"Violation comments"}' https://api.github.com/authorizations

The token needs to be encrypted before added to your .travis.yml.

sudo apt-get install ruby-dev
gem install travis
travis encrypt export GITHUB_OAUTH2TOKEN=YOUR TOKEN HERE

Now add it to .travis.yml like this.

sudo: false  
language: java  
env:  
  - secure: "YOUR ENCRYPTED TOKEN HERE"
jdk:  
  - oraclejdk7
script:  
  - ./gradlew build violationCommentsToGitHub -DGITHUB_PULLREQUESTID=$TRAVIS_PULL_REQUEST -DGITHUB_OAUTH2TOKEN=$GITHUB_OAUTH2TOKEN -i --stacktrace
notifications:  
  email: false

Here I used Gradle plugin but you can do the same thing with Maven plugin.

Developer instructions

To build the code, have a look at .travis.yml.

To do a release you need to do ./gradlew release and release the artifact from staging. More information here.

You can’t perform that action at this time.