Translate

miércoles, 29 de enero de 2025

Git hub Action + Sonar Cloud Error: java.net.UnknownHostException: scanner.sonarcloud.io: Name or service not known

 


Escribo este rápido post por un error que me acaba de ocurrir y ha sido utilizando Sonar Cloud lanzando el flujo de trabajo desde Git Hub actions al hacer un push en el código o un PR. El problema ha surgido con un código que llevaba funcionando desde hace 2 semana pero de repente ha dejado de funcionar dando el siguiente mensaje de error.


Run SonarSource/sonarqube-scan-action@v4.0.0
7
Run ${GITHUB_ACTION_PATH}/sanity-checks.sh
13
Run actions/cache@v4.0.2
23Cache not found for input keys: sonar-scanner-cli-6.2.1.4610-Linux-X64
24
Run ${GITHUB_ACTION_PATH}/install-sonar-scanner-cli.sh
30+ mkdir -p /home/runner/work/_temp/sonarscanner
31+ cd /home/runner/work/_temp/sonarscanner
332025-01-29 15:22:36 URL:https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-6.2.1.4610-linux-x64.zip [57996219/57996219] -> "sonar-scanner-cli-6.2.1.4610-linux-x64.zip" [1]
34+ unzip -q sonar-scanner-cli-6.2.1.4610-linux-x64.zip
35+ mv sonar-scanner-6.2.1.4610-linux-x64 /home/runner/work/_temp/sonar-scanner-cli-6.2.1.4610-Linux-X64
36
Run echo "${RUNNER_TEMP}/sonar-scanner-cli-6.2.1.4610-Linux-X64/bin" >> $GITHUB_PATH
41
Run ${GITHUB_ACTION_PATH}/run-sonar-scanner.sh -Dsonar.projectKey=antuansoft_sonarcloudtest-int -Dsonar.organization=antuansoft
47+ sonar-scanner -Dsonar.projectKey=antuansoft_sonarcloudtest-int -Dsonar.organization=antuansoft
4815:22:38.057 INFO Scanner configuration file: /home/runner/work/_temp/sonar-scanner-cli-6.2.1.4610-Linux-X64/conf/sonar-scanner.properties
4915:22:38.060 INFO Project root configuration file: /home/runner/work/sonarcloudtest-int/sonarcloudtest-int/sonar-project.properties
5015:22:38.075 INFO SonarScanner CLI 6.2.1.4610
5115:22:38.077 INFO Java 17.0.12 Eclipse Adoptium (64-bit)
5215:22:38.078 INFO Linux 6.8.0-1020-azure amd64
5315:22:38.103 INFO User cache: /home/runner/.sonar/cache
5415:22:38.577 INFO JRE provisioning: os[linux], arch[x86_64]
5515:22:39.966 INFO EXECUTION FAILURE
5615:22:39.967 INFO Total time: 1.912s
5715:22:39.968 ERROR Error during SonarScanner CLI execution
59 at org.sonarsource.scanner.lib.internal.http.ScannerHttpClient.callUrl(ScannerHttpClient.java:159)
60 at org.sonarsource.scanner.lib.internal.http.ScannerHttpClient.downloadFile(ScannerHttpClient.java:90)
61 at org.sonarsource.scanner.lib.internal.http.ScannerHttpClient.downloadFromExternalUrl(ScannerHttpClient.java:72)
62 at org.sonarsource.scanner.lib.internal.JavaRunnerFactory$JreDownloader.download(JavaRunnerFactory.java:253)
63 at org.sonarsource.scanner.lib.internal.cache.FileCache.download(FileCache.java:101)
64 at org.sonarsource.scanner.lib.internal.cache.FileCache.getOrDownload(FileCache.java:88)
65 at org.sonarsource.scanner.lib.internal.JavaRunnerFactory.getJreFromServer(JavaRunnerFactory.java:143)
66 at org.sonarsource.scanner.lib.internal.JavaRunnerFactory.createRunner(JavaRunnerFactory.java:85)
67 at org.sonarsource.scanner.lib.internal.ScannerEngineLauncherFactory.createLauncher(ScannerEngineLauncherFactory.java:53)
68 at org.sonarsource.scanner.lib.ScannerEngineBootstrapper.bootstrap(ScannerEngineBootstrapper.java:123)
69 at org.sonarsource.scanner.cli.Main.analyze(Main.java:75)
70 at org.sonarsource.scanner.cli.Main.main(Main.java:63)
71Caused by: java.net.UnknownHostException: scanner.sonarcloud.io: Name or service not known
72 at java.base/java.net.Inet6AddressImpl.lookupAllHostAddr(Native Method)

El código utilizado para lanzar este análisis ha sido desde una github action con este código:

      

name: SonarCloud analysis
on:
  push:
    branches: [ "main" ]
  pull_request:
    branches: [ "main" ]
  workflow_dispatch:

permissions:
  pull-requests: read # allows SonarCloud to decorate PRs with analysis results

jobs:
  Analysis:
    runs-on: ubuntu-latest

    steps:
      - uses: actions/checkout@v4
        with:
          # Disabling shallow clones is recommended for improving the relevancy of reporting
          fetch-depth: 0

      - name: Analyze with SonarCloud
        # You can pin the exact commit or the version.
        # uses: SonarSource/sonarcloud-github-action@v2.2.0
        uses: SonarSource/sonarqube-scan-action@v4.0.0
        env:
          SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}   # Generate a token on Sonarcloud.io, add it to the secrets of this repo with the name SONAR_TOKEN (Settings > Secrets > Actions > add new repository secret)
        with:
          # Additional arguments for the SonarScanner CLI
          args:
            # Unique keys of your project and organization. You can find them in SonarCloud > Information (bottom-left menu)
            # mandatory
            -Dsonar.projectKey=antuansoft_sonarcloudtest-int
            -Dsonar.organization=antuansoft
            # Comma-separated paths to directories containing main source files.
            #-Dsonar.sources= # optional, default is project base directory
            # Comma-separated paths to directories containing test source files.
            #-Dsonar.tests= # optional. For more info about Code Coverage, please refer to https://docs.sonarcloud.io/enriching/test-coverage/overview/
            # Adds more detail to both client and server-side analysis logs, activating DEBUG mode for the scanner, and adding client-side environment variables and system properties to the server-side log of analysis report processing.
            #-Dsonar.verbose= # optional, default is false
          # When you need the analysis to take place in a directory other than the one from which it was launched, default is .
          # projectBaseDir: .
   

El principal problema es que la versión que estamos utilizando de la github action se ha quedado obsoleta, la 4.0.0 y hay que utilizar la versión nueva que a fecha de hoy es la versión 4.2.1

Con lo cual cambiando esta línea a la versión actual todo vuelve a funcionar:
      
uses: SonarSource/sonarqube-scan-action@v4.2.1  
  




Referencias:

No hay comentarios:

Publicar un comentario