Optimize GitLab CI configuration for SonarCloud integration
Added support for caching SonarCloud analysis tasks and updated the Git depth setting to ensure proper branch
This commit is contained in:
+12
-10
@@ -13,6 +13,8 @@ variables:
|
|||||||
SONAR_PROJECT_KEY: "th-schwarz_DynDRest"
|
SONAR_PROJECT_KEY: "th-schwarz_DynDRest"
|
||||||
SONAR_ORGANIZATION: "th-schwarz"
|
SONAR_ORGANIZATION: "th-schwarz"
|
||||||
SONAR_TOKEN: "${SONAR_TOKEN_ENV_VAR}"
|
SONAR_TOKEN: "${SONAR_TOKEN_ENV_VAR}"
|
||||||
|
SONAR_USER_HOME: "${CI_PROJECT_DIR}/.sonar" # Defines the location of the analysis task cache
|
||||||
|
GIT_DEPTH: "0" # Tells git to fetch all the branches of the project, required by the analysis task
|
||||||
|
|
||||||
|
|
||||||
pull_source:
|
pull_source:
|
||||||
@@ -24,7 +26,6 @@ pull_source:
|
|||||||
only:
|
only:
|
||||||
- schedules
|
- schedules
|
||||||
|
|
||||||
|
|
||||||
on_commits:
|
on_commits:
|
||||||
stage: on_commit
|
stage: on_commit
|
||||||
script:
|
script:
|
||||||
@@ -33,19 +34,20 @@ on_commits:
|
|||||||
- mvn clean test
|
- mvn clean test
|
||||||
only:
|
only:
|
||||||
- /^feature.*$/
|
- /^feature.*$/
|
||||||
|
- merge_request
|
||||||
- develop
|
- develop
|
||||||
|
|
||||||
sonarcloud_scan:
|
sonarcloud_scan:
|
||||||
stage: sonarcloud_scan
|
stage: sonarcloud_scan
|
||||||
|
image:
|
||||||
|
name: sonarsource/sonar-scanner-cli:latest
|
||||||
|
entrypoint: [""]
|
||||||
|
cache:
|
||||||
|
key: "${CI_JOB_NAME}"
|
||||||
|
paths:
|
||||||
|
- .sonar/cache
|
||||||
script:
|
script:
|
||||||
- echo "Setting up SonarCloud scan..."
|
- sonar-scanner
|
||||||
- cd ${GITLAB_CLONE_DIR}
|
|
||||||
- |
|
|
||||||
mvn -B verify org.sonarsource.scanner.maven:sonar-maven-plugin:sonar \
|
|
||||||
-Dsonar.host.url=${SONAR_HOST_URL} \
|
|
||||||
-Dsonar.projectKey=${SONAR_PROJECT_KEY} \
|
|
||||||
-Dsonar.organization=${SONAR_ORGANIZATION} \
|
|
||||||
-Dsonar.login=${SONAR_TOKEN}
|
|
||||||
|
|
||||||
only:
|
only:
|
||||||
|
- merge_requests
|
||||||
- develop
|
- develop
|
||||||
|
|||||||
Reference in New Issue
Block a user