feat(Sonar 8): Add additional sonar 8 Template

This commit is contained in:
Marcel Feix 2022-04-04 10:43:27 +02:00 committed by Christian Kaddatz
parent 2be9b65e21
commit 7525e05281
4 changed files with 72 additions and 9 deletions

View File

@ -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].

View File

@ -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[]
----

View File

@ -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

36
tool-sonar8.gitlab-ci.yml Normal file
View File

@ -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"