Skip to content

Commit

Permalink
v2.0-rc1
Browse files Browse the repository at this point in the history
  • Loading branch information
mildis committed Nov 18, 2014
1 parent 09e79d7 commit 3148f10
Show file tree
Hide file tree
Showing 34 changed files with 1,966 additions and 861 deletions.
13 changes: 13 additions & 0 deletions CHANGES
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
Changes with version 2.0 :
* Add authentication scheme selection
* Add l10n for the setting pages
* Add a threshold to vote -1/+1 (global/project)
* Add to enable/disable on Sonar side (global/project)
* Add logs
* Add tests
* Clean-up sonar issues
* Message can contain dynamic values retrived from settings
* Refactor settings view (split server/review settings)

Changes with version 1.0 (1f9567ae16756a202f4631c9b2cbd18adb305960):
* Initial version from TouK https://github.com/TouK/sonar-gerrit-plugin.git
40 changes: 24 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
> This project is abandoned and it's not maintained anymore. If you're looking for alternative please check out Sputnik: https://github.com/TouK/sputnik.
This project is based on original source on https://github.com/TouK/ which was abandonned.


Gerrit Plugin for SonarQube™
============================

This plugin reports SonarQube™ issues on your patchsets to your Gerrit server. SonarQube™ analyses full project, but only files included in patchset are commented on Gerrit

Currently plugin always reports +1 for Code Review, as it's still in development. However, you should always treat these comments as hints to improve, not as direct errors.

I recommend you to try this plugin in conjunction with our other plugin: [Sonar File Alerts Plugin](https://github.com/TouK/sonar-file-alerts-plugin). It alters SonarQube™'s behaviour so alerts can be raised on a file level, not only project level.
Plugin reports -1 or +1 for Code-Review (default) based on severity threshold (default:INFO).

Requirements
------------
Expand All @@ -20,37 +18,47 @@ Requirements
Installation
------------

There is a build package available here: [sonar-gerrit-plugin-1.0.jar](https://github.com/TouK/sonar-gerrit-plugin/releases/download/sonar-gerrit-plugin-1.0/sonar-gerrit-plugin-1.0.jar).

There is a build package available here: [sonar-gerrit-plugin-2.0-rc1.jar](https://github.com/tech-advantage/sonar-gerrit-plugin/releases/download/2.0-rc1/sonar-gerrit-plugin-2.0-rc1.jar).
Or you can build it for yourself. Clone this repository, package it and put a package to your sonar plugins directory.

```bash
mvn package
cp target/sonar-gerrit-plugin-1.0.jar $SONAR_DIR/plugins
mvn clean package
cp target/sonar-gerrit-plugin-2.0.jar $SONAR_DIR/extentions/plugins
$SONAR_DIR/bin/your-architecture-here/sonar.sh restart
```

Configure Jenkins
-----------------

This plugin is intended to use with Gerrit Trigger plugin: https://wiki.jenkins-ci.org/display/JENKINS/Gerrit+Trigger on a Jenkins server.

You need to create a Gerrit user with a HTTP password for him. Then add this user to Non-Interactive Users group.

Then you need to set up Sonar plugin in Jenkins. Log in as admin, Manage Jenkins - Configure System - Sonar - Advanced... - Additional properties: add and adjust your settings:
Then you should set up Sonar plugin in Jenkins. Log in as admin, Manage Jenkins - Configure System - Sonar - Advanced… - Additional properties: add and adjust your settings:

```
-DGERRIT_SCHEME=http -DGERRIT_HTTP_PORT=8080 -DGERRIT_HTTP_USERNAME=sonar -DGERRIT_HTTP_PASSWORD=sonar_password -DGERRIT_BASE_URL=
-DGERRIT_SCHEME=http -DGERRIT_HTTP_PORT=8080 -DGERRIT_HTTP_USERNAME=sonar -DGERRIT_HTTP_PASSWORD=sonar_password
```

Last step is to add Post-Build action - SonarQube™ to every Jenkin's job you want to.

Configure Gerrit
----------------

You need to be able to connect to Gerrit with a valid username and password through HTTP or HTTPS. User can be part of the Non-Interactive Users group.
Plugin vote on Code-Review label. To vote on another label, add a new label on Gerrit and change the plugin settings

```
[label "Quality-Check"]
function = MaxWithBlock
value = -1 Issues to be corrected
value = 0 No score
value = +1 Code is clean
```

How does it work?
-----------------

As SonarQube™ analysis starts, plugin connects to Gerrit and asks what files were changed in a patchset. Sonar iterates on every file and if file is contained in a patchset, plugin collects it's violations and alerts.

When analysis is finished, plugin connects to Gerrit again with collected results.
When analysis is finished, plugin connects to Gerrit again and publish violations and alerts as patchset comments.
Depending on the threshold, plugin votes -1/+1 so submit can be blocked based on your Gerrit settings.

License
-------
Expand Down
117 changes: 66 additions & 51 deletions pom.xml
Original file line number Diff line number Diff line change
@@ -1,37 +1,38 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>

<groupId>pl.touk</groupId>
<groupId>fr.techad</groupId>
<artifactId>sonar-gerrit-plugin</artifactId>
<packaging>sonar-plugin</packaging>
<version>1.1-SNAPSHOT</version>
<version>2.0-rc1</version>

<name>Sonar Gerrit Plugin</name>
<description>Sonar will rate your gerrit patch set and comment on found alerts.</description>
<organization>
<name>TouK</name>
<url>http://touk.pl</url>
</organization>
<url>https://github.com/TouK/sonar-gerrit-plugin</url>
<issueManagement>
<system>github</system>
<url>https://github.com/TouK/sonar-gerrit-plugin/issues</url>
</issueManagement>
<scm>
<url>[email protected]:TouK/sonar-gerrit-plugin.git</url>
<connection>scm:git:https://github.com/TouK/sonar-gerrit-plugin.git</connection>
<developerConnection>scm:git:[email protected]:TouK/sonar-gerrit-plugin.git</developerConnection>
</scm>
<licenses>
<license>
<name>Apache License</name>
</license>
</licenses>
<organization>
<name>TECH'advantage</name>
<url>http://www.techad.fr</url>
</organization>
<url>https://github.com/tech-advantage/sonar-gerrit-plugin</url>
<issueManagement>
<system>github</system>
<url>https://github.com/tech-advantage/sonar-gerrit-plugin/issues</url>
</issueManagement>
<scm>
<url>[email protected]:tech-advantage/sonar-gerrit-plugin.git</url>
<connection>scm:git:https://github.com/tech-advantage/sonar-gerrit-plugin.git</connection>
<developerConnection>scm:git:[email protected]:tech-advantage/sonar-gerrit-plugin.git</developerConnection>
</scm>
<licenses>
<license>
<name>Apache License</name>
</license>
</licenses>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<sonar.buildVersion>4.0</sonar.buildVersion>
<sonar.buildVersion>4.3.2</sonar.buildVersion>
<jdk.min.version>1.6</jdk.min.version>
</properties>

Expand All @@ -42,55 +43,69 @@
<version>${sonar.buildVersion}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
<version>1.2</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>commons-codec</groupId>
<artifactId>commons-codec</artifactId>
<version>1.8</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.codehaus.sonar</groupId>
<artifactId>sonar-testing-harness</artifactId>
<version>${sonar.buildVersion}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<version>4.3.1</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>2.3.0</version>
</dependency>
<dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-all</artifactId>
<version>1.9.5</version>
<version>1.10.8</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.9</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<version>4.3.5</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>2.4.3</version>
</dependency>
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-project</artifactId>
<version>2.2.1</version>
</dependency>
<dependency>
<groupId>com.intellij</groupId>
<artifactId>annotations</artifactId>
<version>12.0</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.9</version>
</dependency>


</dependencies>
<dependency>
<groupId>com.intellij</groupId>
<artifactId>annotations</artifactId>
<version>12.0</version>
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<groupId>org.codehaus.sonar</groupId>
<artifactId>sonar-packaging-maven-plugin</artifactId>
<version>1.1</version>
<version>1.12.1</version>
<extensions>true</extensions>
<configuration>
<pluginClass>pl.touk.sonar.GerritPlugin</pluginClass>
<pluginKey>gerrit</pluginKey>
<pluginName>Gerrit Reviewer</pluginName>
<pluginClass>fr.techad.sonar.GerritPlugin</pluginClass>
</configuration>
</plugin>
<plugin>
Expand All @@ -103,7 +118,7 @@
</configuration>
</plugin>
<plugin>
<!-- UTF-8 bundles are not supported by Java, so they must be converted
<!-- UTF-8 bundles are not supported by Java, so they must be converted
during build -->
<groupId>org.codehaus.mojo</groupId>
<artifactId>native2ascii-maven-plugin</artifactId>
Expand Down
5 changes: 5 additions & 0 deletions src/main/java/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Manifest-Version: 1.0
Created-By: Apache Maven
Built-By: TECH advantage
Build-Jdk: 1.6
Plugin-Class: fr.techad.sonar.GerritPlugin
Loading

0 comments on commit 3148f10

Please sign in to comment.