Jenkins pipeline fails to connect to sonarqube

  • versions used SonarQube 8.3.1-DE, sonarqube gradle plugin 2.8
  • error observed (wrap logs/code around triple quote ``` for proper formatting)
Task :app:compileDebugAndroidTestJavaWithJavac in app Finished
:app:compileDebugAndroidTestJavaWithJavac (Thread[Execution worker for ':' Thread 9,5,main]) completed. Took 0.246 secs.
:app:sonarqube (Thread[Execution worker for ':' Thread 9,5,main]) started.

> Task :app:sonarqube FAILED
Task :app:sonarqube in app Starting
No variant name specified to be used by SonarQube. Default to 'debug'
WARNING: API 'variant.getJavaCompile()' is obsolete and has been replaced with 'variant.getJavaCompileProvider()'.
It will be removed at the end of 2019.
For more information, see https://d.android.com/r/tools/task-configuration-avoidance.
To determine what is calling variant.getJavaCompile(), use -Pandroid.debug.obsoleteApi=true on the command line to display more information.
file or directory '/cde/hudson/workspace/proton-android_sonarqube/app/libs', not found
file or directory '/cde/hudson/workspace/proton-android_sonarqube/app/libs', not found
file or directory '/cde/hudson/workspace/proton-android_sonarqube/app/libs', not found
file or directory '/cde/hudson/workspace/proton-android_sonarqube/app/libs', not found
file or directory '/cde/hudson/workspace/proton-android_sonarqube/app/libs', not found
Caching disabled for task ':app:sonarqube' because:
  Build cache is disabled
Task ':app:sonarqube' is not up-to-date because:
  Task has not declared any outputs despite executing actions.
No variant name specified to be used by SonarQube. Default to 'debug'
file or directory '/cde/hudson/workspace/proton-android_sonarqube/app/libs', not found
file or directory '/cde/hudson/workspace/proton-android_sonarqube/app/libs', not found
file or directory '/cde/hudson/workspace/proton-android_sonarqube/app/libs', not found
file or directory '/cde/hudson/workspace/proton-android_sonarqube/app/libs', not found
file or directory '/cde/hudson/workspace/proton-android_sonarqube/app/libs', not found
User cache: /Users/build/.sonar/cache
SonarQube server ["https://sonarqube.example.com"] can not be reached
Task :app:sonarqube in app Finished
:app:sonarqube (Thread[Execution worker for ':' Thread 9,5,main]) completed. Took 0.106 secs.
AAPT2 aapt2-3.6.3-6040484-osx Daemon #0: shutdown
AAPT2 aapt2-3.6.3-6040484-osx Daemon #1: shutdown
AAPT2 aapt2-3.6.3-6040484-osx Daemon #2: shutdown
AAPT2 aapt2-3.6.3-6040484-osx Daemon #3: shutdown
AAPT2 aapt2-3.6.3-6040484-osx Daemon #4: shutdown
AAPT2 aapt2-3.6.3-6040484-osx Daemon #5: shutdown

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:sonarqube'.
> Unable to execute SonarQube

Did you set systemProp.sonar.login=<token> ?
see https://docs.sonarqube.org/latest/analysis/scan/sonarscanner-for-gradle/

Yes, that property is in the configuration.

OK, but the error message is explicit “can not be reached”.
I guess if it would be the wrong token, we would get another error as e.g. 401unauthorized
Are there any proxies involved !?
In this case you may need to set systemProp.http.nonProxyHosts with ip of your Sonarqube server.

The Jenkins agent running this job is able to reach the specified host from the shell, no proxies involved.

Shell is somewhat different from gradle which is a java process.
Did you double check the sonar.host.url setting in gradle.properties or set as CLI parameter ?
This has to be equal to the server base url set in Sonarqube server.

Yes, the value is correct; l am running over 175 projects against this server. This particular pipeline is being run on a different Jenkins host than some of the other projects. I’m trying to determine why this particular behavior is exhibited from this CI instance.

Did you already replay your pipeline using another Jenkins node ?
If it works on other Jenkins nodes there may be a configuration glitch on that specific node.

I had a similar issue and as previously stated add the login information on the build. I actually created an id just for Jenkins and saved the token/key off somewhere for all jobs to use. Also added the project key. Good luck!