Uploaded image for project: 'Jenkins'
  1. Jenkins
  2. JENKINS-49110

withSonarQubeEnv in Jenkins pipeline not setting SonarQube env whe using Kubernetes

    XMLWordPrintable

    Details

    • Similar Issues:

      Description

      withSonarQubeEnv in Jenkins pipeline is not setting SonarQube environment variables whe using it with Kubernetes:

      [Pipeline] // stage
      [Pipeline] stage
      [Pipeline] { (SonarQube analysis)
      [Pipeline] container
      [Pipeline] {
      Injecting SonarQube environment variables using the configuration: Sonar
      [Pipeline] withSonarQubeEnv
      [Pipeline] {
      [Pipeline] sh
      [_feature_Kubernetes_Jenkins-CRYRJCHOFOQMYJAPU6HZKKE5K4FPOWCOCOI6R45MGFPDF7YMSJEQ] Running shell script
      + sonar-scanner
      INFO: Scanner configuration file: /opt/sonar-scanner-3.0.3.778/conf/sonar-scanner.properties
      INFO: Project root configuration file: /home/jenkins/workspace/_feature_Kubernetes_Jenkins-CRYRJCHOFOQMYJAPU6HZKKE5K4FPOWCOCOI6R45MGFPDF7YMSJEQ/sonar-project.properties
      INFO: SonarQube Scanner 3.0.3.778
      INFO: Java 1.8.0_151 Oracle Corporation (64-bit)
      INFO: Linux 4.4.0-87-generic amd64
      INFO: User cache: /root/.sonar/cache
      ERROR: SonarQube server [http://localhost:9000] can not be reached
      INFO: ------------------------------------------------------------------------
      INFO: EXECUTION FAILURE
      INFO: ------------------------------------------------------------------------
      INFO: Total time: 0.319s
      INFO: Final Memory: 5M/362M
      INFO: ------------------------------------------------------------------------
      ERROR: Error during SonarQube Scanner execution
      org.sonarsource.scanner.api.internal.ScannerException: Unable to execute SonarQube
      	at org.sonarsource.scanner.api.internal.IsolatedLauncherFactory$1.run(IsolatedLauncherFactory.java:84)
      	at org.sonarsource.scanner.api.internal.IsolatedLauncherFactory$1.run(IsolatedLauncherFactory.java:71)
      	at java.security.AccessController.doPrivileged(Native Method)
      	at org.sonarsource.scanner.api.internal.IsolatedLauncherFactory.createLauncher(IsolatedLauncherFactory.java:71)
      	at org.sonarsource.scanner.api.internal.IsolatedLauncherFactory.createLauncher(IsolatedLauncherFactory.java:67)
      	at org.sonarsource.scanner.api.EmbeddedScanner.doStart(EmbeddedScanner.java:218)
      	at org.sonarsource.scanner.api.EmbeddedScanner.start(EmbeddedScanner.java:156)
      	at org.sonarsource.scanner.cli.Main.execute(Main.java:74)
      	at org.sonarsource.scanner.cli.Main.main(Main.java:61)
      Caused by: java.lang.IllegalStateException: Fail to get bootstrap index from server
      	at org.sonarsource.scanner.api.internal.Jars.getBootstrapIndex(Jars.java:100)
      	at org.sonarsource.scanner.api.internal.Jars.getScannerEngineFiles(Jars.java:76)
      	at org.sonarsource.scanner.api.internal.Jars.download(Jars.java:70)
      	at org.sonarsource.scanner.api.internal.JarDownloader.download(JarDownloader.java:39)
      	at org.sonarsource.scanner.api.internal.IsolatedLauncherFactory$1.run(IsolatedLauncherFactory.java:75)
      	... 8 more
      Caused by: java.net.ConnectException: Failed to connect to localhost/0:0:0:0:0:0:0:1:9000
      

      SonarQube is correctly configured and it works when using a simple Docker agent instead of Kubernetes.

       

      I have found a forum with people having the same issue but not an open issue here.

        Attachments

          Issue Links

            Activity

            Hide
            csanchez Carlos Sanchez added a comment -

            this may have been fixed with JENKINS-49465

            Show
            csanchez Carlos Sanchez added a comment - this may have been fixed with JENKINS-49465
            Hide
            allan_burdajewicz Allan BURDAJEWICZ added a comment -

            Carlos Sanchez I could reproduce the same problem with other wrappers like the VaultWrapper and withCredentials. Environment variable are not injected properly. I tested with 1.2.1 with has the fix for https://issues.jenkins-ci.org/browse/JENKINS-49465.

            Show
            allan_burdajewicz Allan BURDAJEWICZ added a comment - Carlos Sanchez I could reproduce the same problem with other wrappers like the VaultWrapper and withCredentials . Environment variable are not injected properly. I tested with 1.2.1 with has the fix for https://issues.jenkins-ci.org/browse/JENKINS-49465 .
            Hide
            csanchez Carlos Sanchez added a comment -

            this is probably the same issue as JENKINS-49370, adding the steps inside container will not work, but adding them outside will

            Show
            csanchez Carlos Sanchez added a comment - this is probably the same issue as JENKINS-49370 , adding the steps inside container will not work, but adding them outside will

              People

              Assignee:
              csanchez Carlos Sanchez
              Reporter:
              fgsalomon Fran Garcia
              Votes:
              2 Vote for this issue
              Watchers:
              5 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved: