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 pot 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:

viernes, 24 de enero de 2025

Katalon runtime engine: Invalid browser: 'Edge (Chromium)'


Hoy el problema que traigo es algo simple pero que está mal en la documentación oficial de Katalon. Katalon es una herramienta de testing automático de front end que permite ejecutar los test utilizando distinos navegadores. 

Esto que voy a contar podemos aplicarlo tanto a la ejecución por linea de comando a través de Katalon runtime engine como en un script de Github actions.


Siguiendo la documentación oficial el parámetro a usar para seleccionar el navegador con el que quieres pasar los tests es -broserType con las siguientes opciones:

En mi caso he puesto los siguientes  comandos para ejecutar la github action para ejecutar los tests de Katalon:


name: katalon Tests Suite MX

on: 

  workflow_dispatch:

jobs:

  build:

    runs-on: windows-latest

    steps:

    - name: Checkout KATALON_STUDIO_ASSIST

      uses: actions/checkout@v4

    - name: Execute Test Suite Test

      uses: katalon-studio/katalon-studio-github-action@v4.0

      with:

         version: '9.6.0'

         projectPath: '${{ github.workspace }}'

         args: '-noSplash -retry=0 -browserType="Edge (Chromium)" -testSuitePath="Test Suites/MX" -apiKey=  ${{ secrets.KATALON_API_KEY }} -executionProfile="QA_Mexico" --config -webui.autoUpdateDrivers=true'


Y en respuesta recibo el siguiente error.

Generating global variables...
578Project 'test' opened
579Start reloading plugins...
584Katalon version: 9.6.0
587Start checking license task
59010:21:52.180 [main] DEBUG com.kms.katalon.core.testdata.TestDataFactory - Finding test data with id 'Data Files/MX/TestData'
59110:21:52.224 [main] DEBUG com.kms.katalon.core.testdata.TestDataFactory - Test data is excel file, reading excel file
59210:21:52.225 [main] DEBUG com.kms.katalon.core.testdata.TestDataFactory - Reading excel file with source file 'D:\a\KATALON_STUDIO_ASSIST\KATALON_STUDIO_ASSIST\MX_TESTDATA.xlsx' and sheet name 'sheet'
596com.kms.katalon.execution.core.exceptions.ExecutionException: com.kms.katalon.execution.exception.InvalidConsoleArgumentException: Invalid browser: 'Edge (Chromium)'
597 at com.kms.katalon.execution.console.entity.TestSuiteLauncherOptionParser.getConsoleLauncher(TestSuiteLauncherOptionParser.java:335)
598 at com.kms.katalon.execution.console.ConsoleExecutor.execute(ConsoleExecutor.java:74)
599 at com.kms.katalon.console.application.ConsoleMain.launch(ConsoleMain.java:158)
600 at com.kms.katalon.console.application.ConsoleApplicationStarter.start(ConsoleApplicationStarter.java:34)
601 at com.kms.katalon.application.Application.runConsole(Application.java:140)
602 at com.kms.katalon.application.Application.start(Application.java:100)
603 at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:203)
604 at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:136)
605 at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:104)
606 at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:402)
607 at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:255)
608 at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
609 at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
610 at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
611 at java.base/java.lang.reflect.Method.invoke(Method.java:568)
612 at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:659)
613 at org.eclipse.equinox.launcher.Main.basicRun(Main.java:596)
614 at org.eclipse.equinox.launcher.Main.run(Main.java:1467)
615Caused by: com.kms.katalon.execution.exception.InvalidConsoleArgumentException: Invalid browser: 'Edge (Chromium)'
616 at com.kms.katalon.execution.console.entity.TestSuiteLauncherOptionParser.createRunConfiguration(TestSuiteLauncherOptionParser.java:416)
617 at com.kms.katalon.execution.console.entity.TestSuiteLauncherOptionParser.internallyBuildRunConfig(TestSuiteLauncherOptionParser.java:379)
618 at com.kms.katalon.execution.console.entity.TestSuiteLauncherOptionParser.buildRunConfig(TestSuiteLauncherOptionParser.java:355)
619 at com.kms.katalon.execution.console.entity.TestSuiteLauncherOptionParser.getConsoleLauncher(TestSuiteLauncherOptionParser.java:332)
620 ... 17 more
621Start clean up session
622End check license task
623End clean up session


La solución es simple basta con quitar los "()" parentesis y poner el parámetro así 

-browserType="Edge Chromium"

Y no como dice la documentación.

Referencias:

Command Line Syntax

Post en el foro de Katalon