Created
November 22, 2024 08:05
-
-
Save unseensenpai/60190c92966c5b898ce6e00fdbd4c797 to your computer and use it in GitHub Desktop.
Sonarcube Setup for Gitlab CI
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| sonarqube-check: | |
| image: mcr.microsoft.com/dotnet/core/sdk:latest | |
| variables: | |
| 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 | |
| cache: | |
| key: "${CI_JOB_NAME}" | |
| paths: | |
| - .sonar/cache | |
| script: | |
| - "apt-get update" | |
| - "apt-get install --yes openjdk-11-jre" | |
| - "dotnet tool install --global dotnet-sonarscanner" | |
| - "export PATH=\"$PATH:$HOME/.dotnet/tools\"" | |
| - "dotnet sonarscanner begin /k:\"$PROJECT_SECRET_KEY\" /d:sonar.login=\"$SONAR_TOKEN\" /d:\"sonar.host.url=$SONAR_HOST_URL\" " | |
| - "dotnet build" | |
| - "dotnet sonarscanner end /d:sonar.login=\"$SONAR_TOKEN\"" | |
| allow_failure: true | |
| only: | |
| - master |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Environment Variables for Gitlab CI | |
| SONAR_TOKEN : sqp_a719####################14f1a | |
| SONAR_HOST_URL : http://localhost:9001 | |
| PROJECT_SECRET_KEY : Lv########Z |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: SonarQube Application | |
| services: | |
| sonarqube: | |
| image: sonarqube:9.9.7-community #Community Latest | |
| depends_on: | |
| - sonar_db | |
| environment: | |
| SONAR_JDBC_URL: jdbc:postgresql://sonar_db:5432/sonar | |
| SONAR_JDBC_USERNAME: sonar | |
| SONAR_JDBC_PASSWORD: sonar | |
| container_name: SonarService | |
| ports: | |
| - "9001:9000" | |
| volumes: | |
| - ./sonarqube_conf:/opt/sonarqube/conf | |
| - ./sonarqube_data:/opt/sonarqube/data | |
| - ./sonarqube_extensions:/opt/sonarqube/extensions | |
| - ./sonarqube_logs:/opt/sonarqube/logs | |
| - ./sonarqube_temp:/opt/sonarqube/temp | |
| sonar_db: | |
| image: postgres:17.1-bookworm #Debian 12 | |
| container_name: SonarDatabase | |
| environment: | |
| POSTGRES_USER: sonar | |
| POSTGRES_PASSWORD: sonar | |
| POSTGRES_DB: sonar | |
| volumes: | |
| - ./sonar_db:/var/lib/postgresql | |
| - ./sonar_db_data:/var/lib/postgresql/data | |
| volumes: | |
| sonarqube_conf: | |
| sonarqube_data: | |
| sonarqube_extensions: | |
| sonarqube_logs: | |
| sonarqube_temp: | |
| sonar_db: | |
| sonar_db_data: |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment