Change CI workflow to SonarQube Analysis #1
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 Analysis | |
| on: | |
| push: | |
| branches: [ "main", "master" ] | |
| pull_request: | |
| branches: [ "main", "master" ] | |
| jobs: | |
| sonarQube: | |
| runs-on: self-hosted | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| - name: Set up JDK 17 | |
| uses: actions/setup-java@v4 | |
| with: | |
| distribution: 'temurin' | |
| java-version: '17' | |
| - name: Cache SonarQube packages | |
| uses: actions/cache@v4 | |
| with: | |
| path: ~/.sonar/cache | |
| key: ${{ runner.os }}-sonar | |
| restore-keys: ${{ runner.os }}-sonar | |
| - name: Install Sonar Scanner | |
| run: | | |
| wget https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-5.0.1.3006-linux.zip | |
| unzip sonar-scanner-cli-5.0.1.3006-linux.zip | |
| mv sonar-scanner-5.0.1.3006-linux sonar-scanner | |
| echo "${{ github.workspace }}/sonar-scanner/bin" >> $GITHUB_PATH | |
| - name: Run SonarQube Analysis | |
| env: | |
| SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} | |
| SONAR_HOST_URL: ${{ secrets.SONAR_HOST_URL }} | |
| run: | | |
| sonar-scanner \ | |
| -Dsonar.projectKey=miProyecto \ | |
| -Dsonar.sources=. \ | |
| -Dsonar.host.url=http://192.168.18.118:9000 \ | |
| -Dsonar.login=sqp_319a2eb1534a8d979042c7d58a14d3080d8ce840 |