From 2124e09ff91d597887d1da382f7eb7757abfbe8f Mon Sep 17 00:00:00 2001
From: OZG-Cloud Team <noreply@ozg-sh.de>
Date: Wed, 24 Feb 2021 10:39:29 +0100
Subject: [PATCH] OZG-199 add sonarqube

---
 Jenkinsfile              |  8 +++++---
 pom.xml                  | 20 ++++++++++++++++++++
 sonar-project.properties |  2 ++
 3 files changed, 27 insertions(+), 3 deletions(-)
 create mode 100644 sonar-project.properties

diff --git a/Jenkinsfile b/Jenkinsfile
index 8867de03..5996a885 100644
--- a/Jenkinsfile
+++ b/Jenkinsfile
@@ -24,9 +24,11 @@ pipeline {
                     FAILED_STAGE=env.STAGE_NAME
                 }
                 container("maven"){
-                    configFileProvider([configFile(fileId: '9aac2fac-7d8d-4128-846b-0a61951df703', variable: 'MAVEN_SETTINGS')]) {
-                        sh 'mvn --version'
-                        sh 'mvn -s $MAVEN_SETTINGS clean install'
+                    withSonarQubeEnv('sonarqube'){
+                        configFileProvider([configFile(fileId: '9aac2fac-7d8d-4128-846b-0a61951df703', variable: 'MAVEN_SETTINGS')]) {
+                            sh 'mvn --version'
+                            sh 'mvn -s $MAVEN_SETTINGS clean install sonar:sonar'
+                        }
                     }
                 }
             }
diff --git a/pom.xml b/pom.xml
index ebcf1880..949c3907 100644
--- a/pom.xml
+++ b/pom.xml
@@ -241,6 +241,26 @@
 				</configuration>
 			</plugin>
 			<!-- end::wsdl[] -->
+			<plugin>
+		    	<groupId>org.jacoco</groupId>
+      			<artifactId>jacoco-maven-plugin</artifactId>
+      			<version>0.8.6</version>
+      			<executions>
+        			<execution>
+          				<id>start-agent</id>
+          				<goals>
+            				<goal>prepare-agent</goal>
+          				</goals>
+        			</execution>
+        			<execution>
+          				<id>generate-report</id>
+          				<phase>package</phase>
+		  				<goals>
+            				<goal>report</goal>
+          				</goals>
+        			</execution>
+      			</executions>
+    		</plugin>
 		</plugins>
 	</build>
 
diff --git a/sonar-project.properties b/sonar-project.properties
new file mode 100644
index 00000000..10d23d8d
--- /dev/null
+++ b/sonar-project.properties
@@ -0,0 +1,2 @@
+sonar.java.coveragePlugin=jacoco
+sonar.jacoco.reportPath=target/jacoco.exec
\ No newline at end of file
-- 
GitLab