Skip to content

Commit

Permalink
Add sonar integration
Browse files Browse the repository at this point in the history
  • Loading branch information
kevinleturc committed Jun 28, 2018
1 parent 97483c5 commit a04d948
Show file tree
Hide file tree
Showing 4 changed files with 179 additions and 32 deletions.
21 changes: 21 additions & 0 deletions Jenkinsfile
Expand Up @@ -47,6 +47,27 @@ node(env.SLAVE) {
sh "${mvnHome}/bin/mvn ${mvnGoals} -P ${env.TARGET_PLATFORM}"
}

// do analysis only on VS Nuxeo master job
if (env.STATUS_CONTEXT_NAME == 'nuxeo/master') {
stage('analysis') {
withEnv(['MAVEN_OPTS=-Xmx1g -server']) {
withCredentials([usernamePassword(credentialsId: 'c4ced779-af65-4bce-9551-4e6c0e0dcfe5', passwordVariable: 'SONARCLOUD_PWD', usernameVariable: '')]) {
if (env.BRANCH_NAME != 'master') {
TARGET_OPTION = "-Dsonar.branch.target=master"
} else {
TARGET_OPTION = ""
}
sh """#!/bin/bash -ex
mvn clean verify sonar:sonar -Dsonar.login=$SONARCLOUD_PWD \
-Dsonar.branch.name=${env.BRANCH_NAME} $TARGET_OPTION \
-P ${env.TARGET_PLATFORM},qa,sonar \
-Dit.jacoco.destFile=$WORKSPACE/target/jacoco-it.exec
"""
}
}
}
}

stage('post build') {
step([$class : 'WarningsPublisher', canComputeNew: false, canResolveRelativePaths: false,
consoleParsers: [[parserName: 'Maven']], defaultEncoding: '', excludePattern: '',
Expand Down
3 changes: 2 additions & 1 deletion README.md
Expand Up @@ -10,7 +10,8 @@ Here is the [Documentation Website](http://nuxeo.github.io/nuxeo-java-client).
[![Jenkins master vs 9.10](https://img.shields.io/jenkins/s/https/qa2.nuxeo.org/jenkins/job/9.10/job/nuxeo-java-client-vs-9.10/job/master.svg?label=Nuxeo%209.10)](https://qa2.nuxeo.org/jenkins/job/9.10/job/nuxeo-java-client-vs-9.10/job/master/)
[![Jenkins master vs 8.10](https://img.shields.io/jenkins/s/https/qa2.nuxeo.org/jenkins/job/8.10/job/nuxeo-java-client-vs-8.10/job/master.svg?label=Nuxeo%208.10)](https://qa2.nuxeo.org/jenkins/job/8.10/job/nuxeo-java-client-vs-8.10/job/master/)
[![Jenkins master vs 7.10](https://img.shields.io/jenkins/s/https/qa2.nuxeo.org/jenkins/job/7.10/job/nuxeo-java-client-vs-7.10/job/master.svg?label=Nuxeo%207.10)](https://qa2.nuxeo.org/jenkins/job/7.10/job/nuxeo-java-client-vs-7.10/job/master/)
[![Dependency Status](https://www.versioneye.com/user/projects/59637bee0fb24f00583adf8e/badge.svg?style=flat-square)](https://www.versioneye.com/user/projects/59637bee0fb24f00583adf8e)
[![Sonar coverage](https://sonarcloud.io/api/project_badges/measure?project=org.nuxeo.client:nuxeo-java-client-parent&metric=coverage)](https://sonarcloud.io/dashboard?id=org.nuxeo.client%3Anuxeo-java-client)
[![Sonar LoC](https://sonarcloud.io/api/project_badges/measure?project=org.nuxeo.client:nuxeo-java-client-parent&metric=ncloc)](https://sonarcloud.io/dashboard?id=org.nuxeo.client%3Anuxeo-java-client)

## Building

Expand Down
20 changes: 1 addition & 19 deletions nuxeo-java-client-test/pom.xml
Expand Up @@ -171,7 +171,7 @@
<artifactId>maven-failsafe-plugin</artifactId>
<version>2.17</version>
<configuration>
<argLine>${it.failsafe.argLine}</argLine>
<argLine>@{it.failsafe.argLine}</argLine>
<trimStackTrace>false</trimStackTrace>
</configuration>
<executions>
Expand Down Expand Up @@ -220,24 +220,6 @@
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<!--<version>0.6.4.201312101107</version>-->
<version>0.7.9</version>
<configuration>
<propertyName>it.failsafe.argLine</propertyName>
<destFile>${java.io.tmpdir}/jacoco-it.dump</destFile>
<append>true</append>
</configuration>
<executions>
<execution>
<goals>
<goal>prepare-agent</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>

Expand Down
167 changes: 155 additions & 12 deletions pom.xml
Expand Up @@ -84,6 +84,7 @@
</modules>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<!-- dependency versions -->
<apache.commons.version>3.6</apache.commons.version>
<commons-io.version>2.5</commons-io.version>
Expand All @@ -94,15 +95,19 @@
<okhttp.version>3.9.1</okhttp.version>
<okio.version>1.13.0</okio.version>
<retrofit.version>2.3.0</retrofit.version>
<!-- plugin dependency versions -->
<plugin.compiler.version>3.6.2</plugin.compiler.version>
<plugin.javadoc.version>2.10.4</plugin.javadoc.version>
<plugin.source.version>3.0.1</plugin.source.version>
<plugin.retrolambda.version>2.5.1</plugin.retrolambda.version>
<!-- other properties -->
<java.version.source>1.8</java.version.source>
<java.version.target>1.7</java.version.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<!-- sonar properties -->
<sonar.host.url>https://sonarcloud.io</sonar.host.url>
<sonar.organization>nuxeo</sonar.organization>
<sonar.dynamicAnalysis>reuseReports</sonar.dynamicAnalysis>
<it.jacoco.destFile>${project.basedir}/target/jacoco-it.exec</it.jacoco.destFile>
<!-- for use in maven-surefire-plugin, maven-failsafe-plugin, jacoco-maven-plugin -->
<it.failsafe.argLine></it.failsafe.argLine>
<!-- for javadoc plugin -->
<additionalparam>-Xdoclint:none</additionalparam>
</properties>

<dependencyManagement>
Expand Down Expand Up @@ -177,6 +182,7 @@
</dependencyManagement>

<profiles>

<profile>
<id>release</id>
<activation>
Expand Down Expand Up @@ -216,15 +222,13 @@
<goals>
<goal>jar</goal>
</goals>
<configuration>
<additionalparam>-Xdoclint:none</additionalparam>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>

<profile>
<id>nightly</id>
<build>
Expand Down Expand Up @@ -263,39 +267,173 @@
</repository>
</distributionManagement>
</profile>

<profile>
<id>sonar</id>
<properties>
<failIfNoTests>false</failIfNoTests>
<maven.test.failure.ignore>true</maven.test.failure.ignore>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<argLine>-Xmx1g -Dfile.encoding=UTF-8 -XX:-OmitStackTraceInFastThrow @{it.failsafe.argLine}</argLine>
</configuration>
</plugin>
</plugins>
</build>
</profile>

</profiles>

<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-enforcer-plugin</artifactId>
<version>1.4.1</version>
<configuration>
<rules>
<requirePluginVersions>
<message>
Set plugin versions in pluginManagement section.
</message>
<banLatest>true</banLatest>
<banRelease>true</banRelease>
<banSnapshots>true</banSnapshots>
</requirePluginVersions>
<requireReleaseDeps>
<message>No Snapshots Allowed!</message>
<onlyWhenRelease>true</onlyWhenRelease>
</requireReleaseDeps>
<requireMavenVersion>
<version>[3.2,)</version>
</requireMavenVersion>
<requireJavaVersion>
<version>[1.8,)</version>
</requireJavaVersion>
</rules>
<skip>false</skip>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-clean-plugin</artifactId>
<version>3.1.0</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
<version>3.1.0</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>${plugin.compiler.version}</version>
<version>3.7.0</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>${plugin.javadoc.version}</version>
<version>3.0.1</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<version>${plugin.source.version}</version>
<version>3.0.1</version>
</plugin>
<plugin>
<groupId>net.orfjackal.retrolambda</groupId>
<artifactId>retrolambda-maven-plugin</artifactId>
<version>${plugin.retrolambda.version}</version>
<version>2.5.4</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.22.0</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>3.1.0</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-install-plugin</artifactId>
<version>2.5.2</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-deploy-plugin</artifactId>
<version>2.8.2</version>
</plugin>
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>0.8.1</version>
<configuration>
<propertyName>it.failsafe.argLine</propertyName>
<destFile>${it.jacoco.destFile}</destFile>
<append>true</append>
</configuration>
<executions>
<execution>
<id>prepare-agent</id>
<goals>
<goal>prepare-agent</goal>
</goals>
</execution>
<execution>
<id>prepare-agent-integration</id>
<goals>
<goal>prepare-agent-integration</goal>
</goals>
</execution>
<execution>
<id>default-report</id>
<goals>
<goal>report</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.sonarsource.scanner.maven</groupId>
<artifactId>sonar-maven-plugin</artifactId>
<version>3.4.0.905</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-site-plugin</artifactId>
<version>3.7.1</version>
</plugin>
<plugin>
<groupId>org.codehaus.sonar-plugins</groupId>
<artifactId>maven-report</artifactId>
<version>0.1</version>
</plugin>
</plugins>
</pluginManagement>

<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-enforcer-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>enforce</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
Expand Down Expand Up @@ -339,6 +477,11 @@
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.codehaus.sonar-plugins</groupId>
<artifactId>maven-report</artifactId>
<version>0.1</version>
</plugin>
</plugins>
</reporting>

Expand Down

1 comment on commit a04d948

@jcarsique
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.