From 2be9b65e218009766fa5cd4799caf0c53faa5f22 Mon Sep 17 00:00:00 2001 From: Christian Kaddatz Date: Fri, 1 Apr 2022 19:10:16 +0200 Subject: [PATCH 1/6] chore: Setup sonar 8 --- tool-sonar7.gitlab-ci.yml | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/tool-sonar7.gitlab-ci.yml b/tool-sonar7.gitlab-ci.yml index c5fbc24..811d702 100644 --- a/tool-sonar7.gitlab-ci.yml +++ b/tool-sonar7.gitlab-ci.yml @@ -1,9 +1,9 @@ .sonar-template-common: stage: test variables: - SONAR_HOST_URL: http://sonar7.exxcellent.de/sonar7 - SONAR_PROJECT_KEY: "" - SONAR_PROJECT_NAME: "" + SONAR_HOST_URL: https://sonar.exxcellent.de/sonar8 + SONAR_PROJECT_KEY: "java_backend_sonar_test" + SONAR_PROJECT_NAME: "java_backend_sonar_test" SONAR_EXCLUSIONS: "**/target/**,**/src/test/**" SONAR_SKIP_BUILD_BREAKER: "true" SONAR_QUERY_MAX_ATTEMPTS_BUILD_BREAKER: "30" @@ -19,9 +19,11 @@ "-Dsonar.projectKey=$SONAR_PROJECT_KEY" "-Dsonar.projectName=$SONAR_PROJECT_NAME" "-Dsonar.exclusions=$SONAR_EXCLUSIONS" - "-Dsonar.buildbreaker.skip=$SONAR_SKIP_BUILD_BREAKER" - "-Dsonar.buildbreaker.queryMaxAttempts=$SONAR_QUERY_MAX_ATTEMPTS_BUILD_BREAKER" - "-Dsonar.buildbreaker.queryInterval=$SONAR_QUERY_INTERVAL_BUILD_BREAKER" + "-Dsonar.qualitygate.wait=true" + "-Dsonar.qualitygate.timeout=30" + #"-Dsonar.buildbreaker.skip=$SONAR_SKIP_BUILD_BREAKER" + #"-Dsonar.buildbreaker.queryMaxAttempts=$SONAR_QUERY_MAX_ATTEMPTS_BUILD_BREAKER" + #"-Dsonar.buildbreaker.queryInterval=$SONAR_QUERY_INTERVAL_BUILD_BREAKER" .sonar-template-gradle: extends: .sonar-template-common From 7525e0528155fb40a5816d0af9e2e254bcd8527e Mon Sep 17 00:00:00 2001 From: Marcel Feix Date: Mon, 4 Apr 2022 10:43:27 +0200 Subject: [PATCH 2/6] feat(Sonar 8): Add additional sonar 8 Template --- .../chapters/templates/tool-sonar7.adoc | 2 +- .../chapters/templates/tool-sonar8.adoc | 29 +++++++++++++++ tool-sonar7.gitlab-ci.yml | 14 ++++---- tool-sonar8.gitlab-ci.yml | 36 +++++++++++++++++++ 4 files changed, 72 insertions(+), 9 deletions(-) create mode 100644 documentation/chapters/templates/tool-sonar8.adoc create mode 100644 tool-sonar8.gitlab-ci.yml diff --git a/documentation/chapters/templates/tool-sonar7.adoc b/documentation/chapters/templates/tool-sonar7.adoc index f838784..a642419 100644 --- a/documentation/chapters/templates/tool-sonar7.adoc +++ b/documentation/chapters/templates/tool-sonar7.adoc @@ -1,6 +1,6 @@ :sourcedir: ../../../ -= sonar-template += Sonar 7 template Ruft den Sonar Job für das Projekt auf. Mehr Details zu finden hier: https://gitlab.exxcellent.de/gilden/ci/exxcellent-sonar-tool[Gilde CI/CD: exxcellent-sonar-tool]. diff --git a/documentation/chapters/templates/tool-sonar8.adoc b/documentation/chapters/templates/tool-sonar8.adoc new file mode 100644 index 0000000..6f1a667 --- /dev/null +++ b/documentation/chapters/templates/tool-sonar8.adoc @@ -0,0 +1,29 @@ +:sourcedir: ../../../ + += Sonar 8 template + +Ruft den Sonar Job für das Projekt auf. +Mehr Details zu finden hier: https://gitlab.exxcellent.de/gilden/ci/exxcellent-sonar-tool[Gilde CI/CD: exxcellent-sonar-tool]. + +.Variables +|=== +|Name |Description | Default Value +|SONAR_HOST_URL | Die URL des eXXcellent sonar servers | http://sonar7.exxcellent.de/sonar7 +|SONAR_TOKEN | Token um geschützte Sonar Funktionen auszuführen | "" +|SONAR_PROJECT_KEY | Der Sonar-Projekt-Key. | "" +|SONAR_PROJECT_NAME | Der Sonar-Projekt-Name. | "" (Es wird dann standardmäßig der Maven project.name verwendet) +|SONAR_EXCLUSIONS | Von Sonar auszuschließende Bereiche | **/target/**,**/src/test/** +|GRADLE_CLI_OPTS | Zusätzliche CLI Opts für Gradle | "" +|SONAR_QUERY_MAX_ATTEMPTS_BUILD_BREAKER | Wie oft soll versucht werden das der Build breaker funktioniert | 30 +|SONAR_QUERY_INTERVAL_BUILD_BREAKER | Wie oft in welchem Intervall soll der Build breaker abgefragt werden | 10000 + +|=== + +TIP: Der SONAR_TOKEN String kann über den persönlichen User Bereich in Sonar unter dem Tab _Security_ erzeugt werden. +Ein technischer User ist aktuell nicht möglich. + +.sonar-template +[source,yaml] +---- +include::{sourcedir}/tool-sonar8.gitlab-ci.yml[] +---- diff --git a/tool-sonar7.gitlab-ci.yml b/tool-sonar7.gitlab-ci.yml index 811d702..c5fbc24 100644 --- a/tool-sonar7.gitlab-ci.yml +++ b/tool-sonar7.gitlab-ci.yml @@ -1,9 +1,9 @@ .sonar-template-common: stage: test variables: - SONAR_HOST_URL: https://sonar.exxcellent.de/sonar8 - SONAR_PROJECT_KEY: "java_backend_sonar_test" - SONAR_PROJECT_NAME: "java_backend_sonar_test" + SONAR_HOST_URL: http://sonar7.exxcellent.de/sonar7 + SONAR_PROJECT_KEY: "" + SONAR_PROJECT_NAME: "" SONAR_EXCLUSIONS: "**/target/**,**/src/test/**" SONAR_SKIP_BUILD_BREAKER: "true" SONAR_QUERY_MAX_ATTEMPTS_BUILD_BREAKER: "30" @@ -19,11 +19,9 @@ "-Dsonar.projectKey=$SONAR_PROJECT_KEY" "-Dsonar.projectName=$SONAR_PROJECT_NAME" "-Dsonar.exclusions=$SONAR_EXCLUSIONS" - "-Dsonar.qualitygate.wait=true" - "-Dsonar.qualitygate.timeout=30" - #"-Dsonar.buildbreaker.skip=$SONAR_SKIP_BUILD_BREAKER" - #"-Dsonar.buildbreaker.queryMaxAttempts=$SONAR_QUERY_MAX_ATTEMPTS_BUILD_BREAKER" - #"-Dsonar.buildbreaker.queryInterval=$SONAR_QUERY_INTERVAL_BUILD_BREAKER" + "-Dsonar.buildbreaker.skip=$SONAR_SKIP_BUILD_BREAKER" + "-Dsonar.buildbreaker.queryMaxAttempts=$SONAR_QUERY_MAX_ATTEMPTS_BUILD_BREAKER" + "-Dsonar.buildbreaker.queryInterval=$SONAR_QUERY_INTERVAL_BUILD_BREAKER" .sonar-template-gradle: extends: .sonar-template-common diff --git a/tool-sonar8.gitlab-ci.yml b/tool-sonar8.gitlab-ci.yml new file mode 100644 index 0000000..e47a4ba --- /dev/null +++ b/tool-sonar8.gitlab-ci.yml @@ -0,0 +1,36 @@ +.sonar-template-common: + stage: test + variables: + SONAR_HOST_URL: https://sonar.exxcellent.de/sonar8 + SONAR_PROJECT_KEY: "" + SONAR_PROJECT_NAME: "" + SONAR_EXCLUSIONS: "**/target/**,**/src/test/**" + SONAR_SKIP_BUILD_BREAKER: "true" + SONAR_QUERY_MAX_ATTEMPTS_BUILD_BREAKER: "30" + SONAR_QUERY_INTERVAL_BUILD_BREAKER: "10000" + +.sonar-template: + extends: .sonar-template-common + image: $MAVEN_IMAGE + script: + - mvn $MAVEN_CLI_OPTS test sonar:sonar + "-Dsonar.host.url=$SONAR_HOST_URL" + "-Dsonar.login=$SONAR_TOKEN" + "-Dsonar.projectKey=$SONAR_PROJECT_KEY" + "-Dsonar.projectName=$SONAR_PROJECT_NAME" + "-Dsonar.exclusions=$SONAR_EXCLUSIONS" + "-Dsonar.qualitygate.wait=§SONAR_QUERY_MAX_ATTEMPTS_BUILD_BREAKER" + "-Dsonar.qualitygate.timeout=$SONAR_QUERY_INTERVAL_BUILD_BREAKER" + +.sonar-template-gradle: + extends: .sonar-template-common + image: $GRADLE_IMAGE + script: + - ./gradlew $GRADLE_OPTS $GRADLE_CLI_OPTS sonarqube + "-Dsonar.host.url=$SONAR_HOST_URL" + "-Dsonar.login=$SONAR_TOKEN" + "-Dsonar.projectKey=$SONAR_PROJECT_KEY" + "-Dsonar.projectName=$SONAR_PROJECT_NAME" + "-Dsonar.exclusions=$SONAR_EXCLUSIONS" + "-Dsonar.qualitygate.wait=$SONAR_QUERY_MAX_ATTEMPTS_BUILD_BREAKER" + "-Dsonar.qualitygate.timeout=$SONAR_QUERY_INTERVAL_BUILD_BREAKER" \ No newline at end of file From 8a0809c3a4c4d3ba15776cae010f3e8991be85b9 Mon Sep 17 00:00:00 2001 From: Marcel Feix Date: Mon, 4 Apr 2022 11:32:37 +0000 Subject: [PATCH 3/6] fix(Sonar 8): Fix Typo in Sonar Query --- tool-sonar8.gitlab-ci.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tool-sonar8.gitlab-ci.yml b/tool-sonar8.gitlab-ci.yml index e47a4ba..b838399 100644 --- a/tool-sonar8.gitlab-ci.yml +++ b/tool-sonar8.gitlab-ci.yml @@ -19,7 +19,7 @@ "-Dsonar.projectKey=$SONAR_PROJECT_KEY" "-Dsonar.projectName=$SONAR_PROJECT_NAME" "-Dsonar.exclusions=$SONAR_EXCLUSIONS" - "-Dsonar.qualitygate.wait=§SONAR_QUERY_MAX_ATTEMPTS_BUILD_BREAKER" + "-Dsonar.qualitygate.wait=$SONAR_QUERY_MAX_ATTEMPTS_BUILD_BREAKER" "-Dsonar.qualitygate.timeout=$SONAR_QUERY_INTERVAL_BUILD_BREAKER" .sonar-template-gradle: @@ -33,4 +33,4 @@ "-Dsonar.projectName=$SONAR_PROJECT_NAME" "-Dsonar.exclusions=$SONAR_EXCLUSIONS" "-Dsonar.qualitygate.wait=$SONAR_QUERY_MAX_ATTEMPTS_BUILD_BREAKER" - "-Dsonar.qualitygate.timeout=$SONAR_QUERY_INTERVAL_BUILD_BREAKER" \ No newline at end of file + "-Dsonar.qualitygate.timeout=$SONAR_QUERY_INTERVAL_BUILD_BREAKER" From e2a52fd44da93ced80d968bd729c98345f521c30 Mon Sep 17 00:00:00 2001 From: Christian Kaddatz Date: Mon, 4 Apr 2022 20:10:55 +0200 Subject: [PATCH 4/6] feat(sonar8): Remove skip build breaker variable --- tool-sonar8.gitlab-ci.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/tool-sonar8.gitlab-ci.yml b/tool-sonar8.gitlab-ci.yml index b838399..fe50c6a 100644 --- a/tool-sonar8.gitlab-ci.yml +++ b/tool-sonar8.gitlab-ci.yml @@ -5,7 +5,6 @@ SONAR_PROJECT_KEY: "" SONAR_PROJECT_NAME: "" SONAR_EXCLUSIONS: "**/target/**,**/src/test/**" - SONAR_SKIP_BUILD_BREAKER: "true" SONAR_QUERY_MAX_ATTEMPTS_BUILD_BREAKER: "30" SONAR_QUERY_INTERVAL_BUILD_BREAKER: "10000" From 26bb72e28e64cde1f1f5e49cf3b9288339eba290 Mon Sep 17 00:00:00 2001 From: Christian Kaddatz Date: Sun, 1 May 2022 21:08:31 +0200 Subject: [PATCH 5/6] chore: Set -Dsonar.qualitygate.wait constantly to true --- tool-sonar8.gitlab-ci.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tool-sonar8.gitlab-ci.yml b/tool-sonar8.gitlab-ci.yml index fe50c6a..724d60e 100644 --- a/tool-sonar8.gitlab-ci.yml +++ b/tool-sonar8.gitlab-ci.yml @@ -18,8 +18,8 @@ "-Dsonar.projectKey=$SONAR_PROJECT_KEY" "-Dsonar.projectName=$SONAR_PROJECT_NAME" "-Dsonar.exclusions=$SONAR_EXCLUSIONS" - "-Dsonar.qualitygate.wait=$SONAR_QUERY_MAX_ATTEMPTS_BUILD_BREAKER" - "-Dsonar.qualitygate.timeout=$SONAR_QUERY_INTERVAL_BUILD_BREAKER" + "-Dsonar.qualitygate.wait=true" + "-Dsonar.qualitygate.timeout=300" .sonar-template-gradle: extends: .sonar-template-common @@ -31,5 +31,5 @@ "-Dsonar.projectKey=$SONAR_PROJECT_KEY" "-Dsonar.projectName=$SONAR_PROJECT_NAME" "-Dsonar.exclusions=$SONAR_EXCLUSIONS" - "-Dsonar.qualitygate.wait=$SONAR_QUERY_MAX_ATTEMPTS_BUILD_BREAKER" + "-Dsonar.qualitygate.wait=$SONAR_QUALITYGATE_WAIT" "-Dsonar.qualitygate.timeout=$SONAR_QUERY_INTERVAL_BUILD_BREAKER" From b7fa794ca221768a225762b8a897f6a99fc6877a Mon Sep 17 00:00:00 2001 From: Marcel Feix Date: Wed, 25 May 2022 11:50:26 +0200 Subject: [PATCH 6/6] chore(Sonar 8): Correct the names of the new Sonar 8 Keys. Change Documentation for Sonar 8. --- documentation/chapters/templates/tool-sonar8.adoc | 7 +++---- tool-sonar8.gitlab-ci.yml | 10 +++++----- 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/documentation/chapters/templates/tool-sonar8.adoc b/documentation/chapters/templates/tool-sonar8.adoc index 6f1a667..1e32ca6 100644 --- a/documentation/chapters/templates/tool-sonar8.adoc +++ b/documentation/chapters/templates/tool-sonar8.adoc @@ -8,14 +8,13 @@ Mehr Details zu finden hier: https://gitlab.exxcellent.de/gilden/ci/exxcellent-s .Variables |=== |Name |Description | Default Value -|SONAR_HOST_URL | Die URL des eXXcellent sonar servers | http://sonar7.exxcellent.de/sonar7 -|SONAR_TOKEN | Token um geschützte Sonar Funktionen auszuführen | "" +|SONAR_HOST_URL | Die URL des eXXcellent sonar servers | https://sonar.exxcellent.de/sonar8 |SONAR_PROJECT_KEY | Der Sonar-Projekt-Key. | "" |SONAR_PROJECT_NAME | Der Sonar-Projekt-Name. | "" (Es wird dann standardmäßig der Maven project.name verwendet) |SONAR_EXCLUSIONS | Von Sonar auszuschließende Bereiche | **/target/**,**/src/test/** |GRADLE_CLI_OPTS | Zusätzliche CLI Opts für Gradle | "" -|SONAR_QUERY_MAX_ATTEMPTS_BUILD_BREAKER | Wie oft soll versucht werden das der Build breaker funktioniert | 30 -|SONAR_QUERY_INTERVAL_BUILD_BREAKER | Wie oft in welchem Intervall soll der Build breaker abgefragt werden | 10000 +|SONAR_QUALITYGATE_WAIT | Definiert, ob auf das Quality-Gate gewartet werden soll. Muss auf True gesetzt werden damit das Quality gate beachtet wird. Wenn das Quality-Gate beachtet werden aber die Pipeline nicht Fehlschlagen soll empfehlen das Flag `allow_failure` auf `true` zu setzen. | true +|SONAR_QUALITYGATE_TIMEOUT | Zeit bis zum Timeout der Quality gate abfrage | 10000 |=== diff --git a/tool-sonar8.gitlab-ci.yml b/tool-sonar8.gitlab-ci.yml index 724d60e..2b0210d 100644 --- a/tool-sonar8.gitlab-ci.yml +++ b/tool-sonar8.gitlab-ci.yml @@ -5,8 +5,8 @@ SONAR_PROJECT_KEY: "" SONAR_PROJECT_NAME: "" SONAR_EXCLUSIONS: "**/target/**,**/src/test/**" - SONAR_QUERY_MAX_ATTEMPTS_BUILD_BREAKER: "30" - SONAR_QUERY_INTERVAL_BUILD_BREAKER: "10000" + SONAR_QUALITYGATE_WAIT: "true" + SONAR_QUALITYGATE_TIMEOUT: "10000" .sonar-template: extends: .sonar-template-common @@ -18,8 +18,8 @@ "-Dsonar.projectKey=$SONAR_PROJECT_KEY" "-Dsonar.projectName=$SONAR_PROJECT_NAME" "-Dsonar.exclusions=$SONAR_EXCLUSIONS" - "-Dsonar.qualitygate.wait=true" - "-Dsonar.qualitygate.timeout=300" + "-Dsonar.qualitygate.wait=$SONAR_QUALITYGATE_WAIT" + "-Dsonar.qualitygate.timeout=$SONAR_QUALITYGATE_TIMEOUT" .sonar-template-gradle: extends: .sonar-template-common @@ -32,4 +32,4 @@ "-Dsonar.projectName=$SONAR_PROJECT_NAME" "-Dsonar.exclusions=$SONAR_EXCLUSIONS" "-Dsonar.qualitygate.wait=$SONAR_QUALITYGATE_WAIT" - "-Dsonar.qualitygate.timeout=$SONAR_QUERY_INTERVAL_BUILD_BREAKER" + "-Dsonar.qualitygate.timeout=$SONAR_QUALITYGATE_TIMEOUT"