Skip to content
This repository has been archived by the owner on Jul 30, 2023. It is now read-only.

tomasbjerre/violation-comments-to-github-jenkins-plugin

 
 

Repository files navigation

Violation Comments to GitHub Jenkins Plugin

Build Status


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:

There is also:

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.

Post build action menu

The pull request will be commented like this.

Pull request comment

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

About

Jenkins plugin that comments GitHub pull requests with code analyzer comments.

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Java 96.6%
  • HTML 1.3%
  • Mustache 1.2%
  • Shell 0.9%