Skip to content

Commit

Permalink
Merge pull request #6 from aquarellian/master
Browse files Browse the repository at this point in the history
JENKINS-31238
  • Loading branch information
aquarellian committed Nov 18, 2015
2 parents fb4faf4 + 9087155 commit 2ad6f55
Show file tree
Hide file tree
Showing 15 changed files with 68 additions and 54 deletions.
43 changes: 29 additions & 14 deletions pom.xml
@@ -1,12 +1,13 @@
<?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>

<parent>
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>plugin</artifactId>
<version>1.580.1</version>
<relativePath />
<relativePath/>
</parent>

<artifactId>sonar-gerrit</artifactId>
Expand All @@ -24,22 +25,23 @@
</licenses>

<developers>
<developer>
<id>aquarellian</id>
<name>Tatiana Didik (Goretskaya)</name>
<email>aquarellian@gmail.com</email>
</developer>
<developer>
<id>adidik</id>
<name>Aleksey Didik</name>
</developer>
<developer>
<id>aquarellian</id>
<name>Tatiana Didik (Goretskaya)</name>
<email>aquarellian@gmail.com</email>
</developer>
<developer>
<id>adidik</id>
<name>Aleksey Didik</name>
</developer>
</developers>
<scm>
<connection>scm:git:ssh://github.com/jenkinsci/${project.artifactId}-plugin.git</connection>
<developerConnection>scm:git:ssh://git@github.com/jenkinsci/${project.artifactId}-plugin.git</developerConnection>
<developerConnection>scm:git:ssh://git@github.com/jenkinsci/${project.artifactId}-plugin.git
</developerConnection>
<url>https://github.com/jenkinsci/${project.artifactId}-plugin</url>
<tag>sonar-gerrit-1.0.2</tag>
</scm>
<tag>sonar-gerrit-1.0.2</tag>
</scm>

<repositories>
<repository>
Expand All @@ -54,6 +56,19 @@
</pluginRepository>
</pluginRepositories>

<build>
<plugins>
<plugin>
<groupId>org.jenkins-ci.tools</groupId>
<artifactId>maven-hpi-plugin</artifactId>
<extensions>true</extensions>
<configuration>
<compatibleSinceVersion>1.0</compatibleSinceVersion>
</configuration>
</plugin>
</plugins>
</build>

<dependencies>
<dependency>
<groupId>com.sonyericsson.hudson.plugins.gerrit</groupId>
Expand Down
3 changes: 1 addition & 2 deletions src/main/resources/index.jelly
@@ -1,7 +1,6 @@
<?jelly escape-by-default='true'?>
<!--
This view is used to render the installed plugins page.
-->
<div>
This plugin allows to submit issues from Sonar to Gerrit as comments directly.
This plugin allows to submit issues from <a href="http://www.sonarqube.org/">SonarQube</a> to <a href="https://www.gerritcodereview.com">Gerrit</a> as comments directly.
</div>
12 changes: 6 additions & 6 deletions src/main/resources/messages.properties
@@ -1,20 +1,20 @@
jenkins.plugin.build.step.name=Post Sonar issues as Gerrit comments
jenkins.plugin.build.step.name=Post SonarQube issues as Gerrit comments

jenkins.plugin.validation.path.empty=Please set a path
jenkins.plugin.validation.path.no.such.file=No such file: %s
jenkins.plugin.validation.sonar.url.empty=Please set Sonar URL
jenkins.plugin.validation.sonar.url.empty=Please set SonarQube URL
jenkins.plugin.validation.sonar.url.invalid=Please set valid URL
jenkins.plugin.validation.review.title.empty=Please fill up report title template
jenkins.plugin.validation.review.body.empty=Please fill up report body template

jenkins.plugin.default.review.body=<severity> Sonar violation:\n\n\n<message>\n\n\nRead more: <rule_url>
jenkins.plugin.default.review.title.no.issues=Sonar violations have not been found.
jenkins.plugin.default.review.title.issues=<total_count> Sonar violations have been found.
jenkins.plugin.default.review.body=<severity> SonarQube violation:\n\n\n<message>\n\n\nRead more: <rule_url>
jenkins.plugin.default.review.title.no.issues=SonarQube violations have not been found.
jenkins.plugin.default.review.title.issues=<total_count> SonarQube violations have been found.

jenkins.plugin.error.gerrit.server.empty=Cannot obtain Gerrit server name. Please check your Gerrit Trigger settings
jenkins.plugin.error.gerrit.config.empty=Cannot obtain Gerrit configuration. Please check your Gerrit Trigger settings
jenkins.plugin.error.gerrit.user.empty=Gerrit authentication is not configured. Please check Gerrit Trigger settings
jenkins.plugin.error.sonar.report.not.exists=Sonar report '%s' does not exist. Please check plugin settings
jenkins.plugin.error.sonar.report.not.exists=SonarQube report '%s' does not exist. Please check plugin settings
jenkins.plugin.validation.review.severity.unknown=Unknown severity
jenkins.plugin.validation.review.category.unknown=Unknown category
jenkins.plugin.validation.review.score.not.numeric=Score should be numeric
Expand Down
@@ -1,15 +1,15 @@
jenkins.plugin.settings.section.sonar.name=Sonar Settings
jenkins.plugin.settings.sonar.url=Sonar URL
jenkins.plugin.settings.sonar.report.path=Sonar report path
jenkins.plugin.settings.section.sonar.name=SonarQube Settings
jenkins.plugin.settings.sonar.url=SonarQube URL
jenkins.plugin.settings.sonar.report.path=SonarQube report path
jenkins.plugin.settings.section.filter.name=Filter Settings
jenkins.plugin.settings.filter.severity=Report issues having severity level higher or equal to:
jenkins.plugin.settings.filter.new=Report new issues only?
jenkins.plugin.settings.filter.new.description=Reports new as well as existing issues when unchecked
jenkins.plugin.settings.filter.lines.changed=Add comments to changed lines only
jenkins.plugin.settings.filter.lines.changed.description=Reports issues for changed as well as not changed lines in files affected by patchset when unchecked
jenkins.plugin.settings.section.review.format.name=Report Format
jenkins.plugin.settings.review.format.title.no.issues=Title of review for no Sonar violations found case
jenkins.plugin.settings.review.format.title.issues=Title of review for Sonar violations found case
jenkins.plugin.settings.review.format.title.no.issues=Title of review for no SonarQube violations found case
jenkins.plugin.settings.review.format.title.issues=Title of review for SonarQube violations found case
jenkins.plugin.settings.review.format.body=Pattern for issue comment
jenkins.plugin.settings.section.project.name=Project Settings
jenkins.plugin.settings.project.base.path=Project base directory
Expand All @@ -20,20 +20,20 @@ MAJOR=Major
CRITICAL=Critical
BLOCKER=Blocker

jenkins.plugin.default.review.body=<severity> Sonar violation:\n\n\n<message>\n\n\nRead more: <rule_url>
jenkins.plugin.default.review.title.no.issues=Sonar violations have not been found.
jenkins.plugin.default.review.title.issues=<total_count> Sonar violations have been found.
jenkins.plugin.default.review.body=<severity> SonarQube violation:\n\n\n<message>\n\n\nRead more: <rule_url>
jenkins.plugin.default.review.title.no.issues=SonarQube violations have not been found.
jenkins.plugin.default.review.title.issues=<total_count> SonarQube violations have been found.

jenkins.plugin.settings.section.gerrit.name=Gerrit Settings
jenkins.plugin.settings.gerrit.post.score=Post score?
jenkins.plugin.settings.gerrit.post.score.description=This setting describes whether it is necessary to post score to Gerrit or not
jenkins.plugin.settings.gerrit.category=Category
jenkins.plugin.settings.gerrit.score.no.issues=Score for no Sonar violations found case
jenkins.plugin.settings.gerrit.score.issues=Score for Sonar violations found case
jenkins.plugin.settings.gerrit.score.no.issues=Score for no SonarQube violations found case
jenkins.plugin.settings.gerrit.score.issues=Score for SonarQube violations found case

jenkins.plugin.settings.section.notification.settings.name=Notification Settings
jenkins.plugin.settings.notification.no.issues=To be notified if no Sonar violations found
jenkins.plugin.settings.notification.issues=To be notified if several Sonar violations found
jenkins.plugin.settings.notification.no.issues=To be notified if no SonarQube violations found
jenkins.plugin.settings.notification.issues=To be notified if several SonarQube violations found

NONE=None
OWNER=Owner
Expand Down
@@ -1,13 +1,13 @@
<div>
This text will appear as comment for a line with Sonar issue in Gerrit review. <br/>
This text will appear as comment for a line with SonarQube issue in Gerrit review. <br/>
There are some tags available: <br/>
<br/>
* &lt;key&gt; - will be replaced with <b>issue key</b>; <br/>
* &lt;component&gt; - will be replaced with <b>issue component info</b>; <br/>
* &lt;message&gt; - will be replaced with <b>issue message</b>; <br/>
* &lt;severity&gt; - will be replaced with <b>issue severity</b>; <br/>
* &lt;rule&gt; - will be replaced with <b>issue rule name</b>; <br/>
* &lt;rule_url&gt; - will be replaced with link to <b>rule description on Sonar</b> if Sonar URL is provided in Sonar settings section or <b>rule name</b> if URL is not provided; <br/>
* &lt;rule_url&gt; - will be replaced with link to <b>rule description on SonarQube</b> if SonarQube URL is provided in SonarQube settings section or <b>rule name</b> if URL is not provided; <br/>
* &lt;status&gt; - will be replaced with <b>issue status</b>; <br/>
* &lt;creation_date&gt; - will be replaced with <b>issue creation date</b>. <br/>
<br/>
Expand Down
@@ -1,5 +1,5 @@
<div>
This setting allow to determine who will be notified in case there are <b>several Sonar issues matching filter settings</b> found in particular commit. <br/>
This setting allow to determine who will be notified in case there are <b>several SonarQube issues matching filter settings</b> found in particular commit. <br/>
An e-mails sent to recipients will contain review information: title of review and list of comments (issues).
Recipient settings: <br/>
<br/>
Expand Down
@@ -1,3 +1,3 @@
<div>
Score to be posted to Gerrit in case when there are Sonar violations found
Score to be posted to Gerrit in case when there are SonarQube violations found
</div>
@@ -1,4 +1,4 @@
<div>
Check if you want only <b>new</b> Sonar issues to be commented in Gerrit.
Check if you want only <b>new</b> SonarQube issues to be commented in Gerrit.
If you want modified files to be commented with <b>all</b> corresponding issues leave this control unchecked.
</div>
@@ -1,5 +1,5 @@
<div>
This setting allow to determine who will be notified in case there are <b>no Sonar issues matching filter settings</b> found in particular commit. <br/>
This setting allow to determine who will be notified in case there are <b>no SonarQube issues matching filter settings</b> found in particular commit. <br/>
An e-mails sent to recipients will contain review information: title of review.
Recipient settings: <br/>
<br/>
Expand Down
@@ -1,3 +1,3 @@
<div>
Score to be posted to Gerrit in case when there are no Sonar violations found
Score to be posted to Gerrit in case when there are no SonarQube violations found
</div>
@@ -1,3 +1,3 @@
<div>
Location of Sonar report file on your Jenkins server. By default Jenkins uses "target/sonar/sonar-report.json"
Location of SonarQube report file on your Jenkins server. By default Jenkins uses "target/sonar/sonar-report.json"
</div>
@@ -1,3 +1,3 @@
<div>
Minimum level of Sonar> severity to be reported to Gerrit.
Minimum level of SonarQube severity to be reported to Gerrit.
</div>
@@ -1,3 +1,3 @@
<div>
URL of Sonar instance that is used for analysis. It is used to provide a link to a Sonar rule in Gerrit comments.
URL of SonarQube instance that is used for analysis. It is used to provide a link to a SonarQube rule in Gerrit comments.
</div>
Expand Up @@ -23,17 +23,17 @@ public class CustomIssueFormatterTest {
@Test
public void testKnownUrl() throws IOException, InterruptedException, URISyntaxException {
Issue i = getIssue();
String text = "<severity> Sonar violation:\n\n\n<message>\n\n\nRead more: <rule_url>";
String expectedResult = "MINOR Sonar violation:\n\n\nRemove this unused import 'com.magenta.guice.property.PropertiesHandler'.\n\n\nRead more: http://localhost:9000/coding_rules#rule_key=squid%3AUselessImportCheck";
String text = "<severity> SonarQube violation:\n\n\n<message>\n\n\nRead more: <rule_url>";
String expectedResult = "MINOR SonarQube violation:\n\n\nRemove this unused import 'com.magenta.guice.property.PropertiesHandler'.\n\n\nRead more: http://localhost:9000/coding_rules#rule_key=squid%3AUselessImportCheck";
CustomIssueFormatter basicIssueConverter = new CustomIssueFormatter(i, text, "http://localhost:9000");
Assert.assertEquals(expectedResult, basicIssueConverter.getMessage());
}

@Test
public void testUnknownUrl() throws IOException, InterruptedException, URISyntaxException {
Issue i = getIssue();
String text = "<severity> Sonar violation:\n\n\n<message>\n\n\nRead more: <rule_url>";
String expectedResult = "MINOR Sonar violation:\n\n\nRemove this unused import 'com.magenta.guice.property.PropertiesHandler'.\n\n\nRead more: squid:UselessImportCheck";
String text = "<severity> SonarQube violation:\n\n\n<message>\n\n\nRead more: <rule_url>";
String expectedResult = "MINOR SonarQube violation:\n\n\nRemove this unused import 'com.magenta.guice.property.PropertiesHandler'.\n\n\nRead more: squid:UselessImportCheck";
CustomIssueFormatter basicIssueConverter = new CustomIssueFormatter(i, text, null);
Assert.assertEquals(expectedResult, basicIssueConverter.getMessage());
}
Expand Down
Expand Up @@ -22,8 +22,8 @@
* $Id$
*/
public class CustomReportFormatterTest {
private static String SUCCESS_TEXT = "Sonar violations have not been found.";
private static String FAIL_TEXT = "<total_count> Sonar violations have been found.\n" +
private static String SUCCESS_TEXT = "SonarQube violations have not been found.";
private static String FAIL_TEXT = "<total_count> SonarQube violations have been found.\n" +
"Info: <info_count>\n" +
"Minor: <minor_count>\n" +
"Major: <major_count>\n" +
Expand All @@ -36,15 +36,15 @@ public class CustomReportFormatterTest {
@Test
public void testSuccess() throws IOException, InterruptedException, URISyntaxException {
List<Issue> i = new ArrayList<Issue>();
String expectedResult = "Sonar violations have not been found.";
String expectedResult = "SonarQube violations have not been found.";
CustomReportFormatter basicIssueConverter = new CustomReportFormatter(i, FAIL_TEXT, SUCCESS_TEXT);
Assert.assertEquals(expectedResult, basicIssueConverter.getMessage());
}

@Test
public void testFail() throws IOException, InterruptedException, URISyntaxException {
List<Issue> i = getIssues();
String expectedResult = "19 Sonar violations have been found.\n" +
String expectedResult = "19 SonarQube violations have been found.\n" +
"Info: 1\n" +
"Minor: 6\n" +
"Major: 10\n" +
Expand All @@ -60,7 +60,7 @@ public void testFail() throws IOException, InterruptedException, URISyntaxExcept
@Test
public void testSuccessEmpty() throws IOException, InterruptedException, URISyntaxException {
List<Issue> i = new ArrayList<Issue>();
String expectedResult = "Sonar violations have not been found.";
String expectedResult = "SonarQube violations have not been found.";
CustomReportFormatter basicIssueConverter = new CustomReportFormatter(i, "", "");
Assert.assertEquals(expectedResult, basicIssueConverter.getMessage());
basicIssueConverter = new CustomReportFormatter(i, null, null);
Expand All @@ -70,7 +70,7 @@ public void testSuccessEmpty() throws IOException, InterruptedException, URISynt
@Test
public void testFailEmpty() throws IOException, InterruptedException, URISyntaxException {
List<Issue> i = getIssues();
String expectedResult = "19 Sonar violations have been found.";
String expectedResult = "19 SonarQube violations have been found.";
CustomReportFormatter basicIssueConverter = new CustomReportFormatter(i, "", "");
Assert.assertEquals(expectedResult, basicIssueConverter.getMessage());
basicIssueConverter = new CustomReportFormatter(i, null, null);
Expand Down

0 comments on commit 2ad6f55

Please sign in to comment.