feat(Sonar 8): Add Sonar 8 Support and Documentation.

This commit is contained in:
Marcel Feix 2022-05-25 11:50:26 +02:00
parent 9acbb1ba46
commit 83aada8d2c
No known key found for this signature in database
GPG Key ID: 04D016E104A25F03
7 changed files with 82 additions and 14 deletions

View File

@ -1,7 +1,8 @@
:sourcedir: ../../../../templates/
= sonar-template
= Sonar 7
The following templates provide integrations for Sonar
More Details can be found here: https://www.exxcellent.de/confluence/x/RIWCC[Confluence: Sonar Plugin Setup].
.Variables
|===
@ -22,5 +23,5 @@ Wenn der Build nicht gebrochen werden soll, kann es weggelassen werden.
.sonar-template
[source,yaml]
----
include::{sourcedir}static-analysis/sonar.gitlab-ci.yml[]
include::{sourcedir}static-analysis/sonar-7.gitlab-ci.yml[]
----

View File

@ -0,0 +1,25 @@
:sourcedir: ../../../../templates/
= Sonar 8
The following templates provide integrations for Sonar
More Details can be found here: https://www.exxcellent.de/confluence/x/RIWCC[Confluence: Sonar Plugin Setup].
.Variables
|===
|Name |Description | Default Value
|SONAR_HOST_URL | The Url for the Sonar server | https://sonar.exxcellent.de/sonar8
|SONAR_TOKEN | The Sonar token to call protected sonar functions | ""
|SONAR_PROJECT_KEY | The Sonar-Projekt-Key of your Project. | ""
|SONAR_PROJECT_NAME | The Sonar-Projekt-Name. | "" (Es wird dann standardmäßig der Maven project.name verwendet)
|SONAR_EXCLUSIONS | Paths that will not be scanned by Sonar | **/target/**,**/src/test/**
|SONAR_QUALITYGATE_WAIT | Defines if the quality-gate should be considered while evaluation.
Has to be `true` if the quality-gate should fail your pipelines. Please consider setting `allow_failure` to `true` if your pipeline shouldn't fail but the quality gate should be still called. | true
|SONAR_QUALITYGATE_TIMEOUT | Define the timeout time when the quality-gate should be timing out. | 10000
|===
.sonar-template
[source,yaml]
----
include::{sourcedir}static-analysis/sonar-8.gitlab-ci.yml[]
----

View File

@ -104,7 +104,7 @@ include::chapters/templates/java/gradle/gradle-db-diff-template.adoc[leveloffset
With the following collection we provide Static code and Artefact analysis tools.
include::chapters/templates/static-analysis/repo-cve-scan.adoc[leveloffset=2]
include::chapters/templates/static-analysis/tool-sonar.adoc[leveloffset=2]
include::chapters/templates/static-analysis/sonar-7.adoc[leveloffset=2]
== Documentation

View File

@ -2,7 +2,13 @@ include:
- '/templates/java/gradle/gradle-build.gitlab-ci.yml'
- '/templates/java/gradle/gradle-verify.gitlab-ci.yml'
- '/templates/static-analysis/repo-cve-scan-trivy.gitlab-ci.yml'
- '/templates/static-analysis/sonar.gitlab-ci.yml'
- '/templates/static-analysis/sonar-8.gitlab-ci.yml'
# todo docs
# todo Variablen die gesetzt werden müssen
# variables:
# SONAR_PROJECT_KEY: ""
Build-Java:
extends: .gradle-build
@ -23,5 +29,4 @@ sonar:
- job: "Build-Java"
artifacts: true
variables:
SONAR_PROJECT_KEY: $CI_PROJECT_NAME
SONAR_PROJECT_NAME: $CI_PROJECT_NAME

View File

@ -4,9 +4,11 @@ include:
- '/templates/java/maven/maven-verify.gitlab-ci.yml'
- '/templates/java/maven/maven-database-diff.gitlab-ci.yml'
- '/templates/static-analysis/repo-cve-scan-trivy.gitlab-ci.yml'
- '/templates/static-analysis/sonar.gitlab-ci.yml'
- '/templates/static-analysis/sonar-8.gitlab-ci.yml'
# todo doc welche Variablen gesetzt werden müssen.before_script:
# todo docs
# todo Variablen die gesetzt werden müssen
# variables:
# SONAR_PROJECT_KEY: ""
@ -25,12 +27,13 @@ Test-Java:
- job: "Build-Java"
artifacts: true
Database-Diff:
extends:
- .maven-database-diff
needs:
- job: "Build-Java"
artifacts: true
#todo put this into backend template
#Database-Diff:
# extends:
# - .maven-database-diff
# needs:
# - job: "Build-Java"
# artifacts: true
Repo-CVE-Scan:
allow_failure: true
@ -42,5 +45,4 @@ Sonar:
- job: "Build-Java"
artifacts: true
variables:
SONAR_PROJECT_KEY: $CI_PROJECT_NAME
SONAR_PROJECT_NAME: $CI_PROJECT_NAME

View File

@ -0,0 +1,35 @@
.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_QUALITYGATE_WAIT: "true"
SONAR_QUALITYGATE_TIMEOUT: "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_QUALITYGATE_WAIT"
"-Dsonar.qualitygate.timeout=$SONAR_QUALITYGATE_TIMEOUT"
.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_QUALITYGATE_WAIT"
"-Dsonar.qualitygate.timeout=$SONAR_QUALITYGATE_TIMEOUT"