diff --git a/documentation/chapters/templates/static-analysis/tool-sonar.adoc b/documentation/chapters/templates/static-analysis/sonar-7.adoc similarity index 85% rename from documentation/chapters/templates/static-analysis/tool-sonar.adoc rename to documentation/chapters/templates/static-analysis/sonar-7.adoc index 445b9b9..0f1b9df 100644 --- a/documentation/chapters/templates/static-analysis/tool-sonar.adoc +++ b/documentation/chapters/templates/static-analysis/sonar-7.adoc @@ -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[] ---- diff --git a/documentation/chapters/templates/static-analysis/sonar-8.adoc b/documentation/chapters/templates/static-analysis/sonar-8.adoc new file mode 100644 index 0000000..a7e4a21 --- /dev/null +++ b/documentation/chapters/templates/static-analysis/sonar-8.adoc @@ -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[] +---- diff --git a/documentation/document.adoc b/documentation/document.adoc index 6d4391a..93af2d9 100644 --- a/documentation/document.adoc +++ b/documentation/document.adoc @@ -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 diff --git a/pipelines/java-gradle.gitlab-ci.yml b/pipelines/java-gradle.gitlab-ci.yml index 37c1568..8c14bfa 100644 --- a/pipelines/java-gradle.gitlab-ci.yml +++ b/pipelines/java-gradle.gitlab-ci.yml @@ -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 diff --git a/pipelines/java-maven.gitlab-ci.yml b/pipelines/java-maven.gitlab-ci.yml index 5f681ec..ca9a325 100644 --- a/pipelines/java-maven.gitlab-ci.yml +++ b/pipelines/java-maven.gitlab-ci.yml @@ -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 diff --git a/templates/static-analysis/sonar.gitlab-ci.yml b/templates/static-analysis/sonar-7.gitlab-ci.yml similarity index 100% rename from templates/static-analysis/sonar.gitlab-ci.yml rename to templates/static-analysis/sonar-7.gitlab-ci.yml diff --git a/templates/static-analysis/sonar-8.gitlab-ci.yml b/templates/static-analysis/sonar-8.gitlab-ci.yml new file mode 100644 index 0000000..44e9047 --- /dev/null +++ b/templates/static-analysis/sonar-8.gitlab-ci.yml @@ -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"