Hello Support, I am evaluating SonarQube (SQ) Server Developer and have come across a couple problems and haven’t found an appropriate solution for either.
Before reading into the problem, I need to present my setup.
sonarqube-developer-2025.1.0.102418.zip
sonar-scanner-cli-7.0.2.4839-windows-x64.zip
I have a developer laptop in which I can install and do anything I need and it is this laptop that I am doing my SQ Server evaluation.
I have a secondary laptop with IT locks that only receives the email from GitHub actions - no SQ setup or Java etc.
On my developer laptop:
I have setup SonarQube Server with GitHub Actions and authorized GitHub - plus added the SonarQ app to GitHub.
I have also added these extensions to VSCode. I also have the appropriate SONAR_TOKEN and SONAR_HOST_URL as well as sonar-project.properties and .github/workflows/build.yml.
The main issue I have is getting the auto-generation of the warnings from SQ server after a GitHub push.
I can manually run the following command and get the expected results on the server (http://localhost:9000) under the project I setup - with some 1000 warnings:
sonar-scanner.bat -D"sonar.projectKey=" -D"sonar.host.url=http://localhost:9000" -D"sonar.token=" -X
However, I always get an email back (the other laptop) with this in it: Build: All jobs have failed
If I click the ‘View workflow run’ button, I always see this:
Set up job - Checked
Run actions/checkout@v4 - Checked
Run SonarSource/sonarcube-scan-action@v4 - red X
Run actions/cache@v4
Cache not found for input keys: sonar-scanner-cli-6.2.1.4610-Windows-X64
Run ${GITHUB_ACTION_PATH}/scripts/install-sonar-scanner-cli.sh
+ mkdir -p 'D:\a\_temp/sonarscanner'
+ cd 'D:\a\_temp/sonarscanner'
+ SCANNER_FILE_NAME=sonar-scanner-cli-6.2.1.4610-windows-x64.zip
+ SCANNER_URI=https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-6.2.1.4610-windows-x64.zip
+ command -v wget
+ command -v curl
+ curl --fail --silent --show-error --user-agent sonarqube-scan-action --location --output sonar-scanner-cli-6.2.1.4610-windows-x64.zip https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-6.2.1.4610-windows-x64.zip
+ unzip -q -o sonar-scanner-cli-6.2.1.4610-windows-x64.zip
+ SCANNER_UNZIP_FOLDER=sonar-scanner-6.2.1.4610-windows-x64
+ SCANNER_LOCAL_FOLDER='D:\a\_temp/sonar-scanner-cli-6.2.1.4610-Windows-X64'
+ '[' -d 'D:\a\_temp/sonar-scanner-cli-6.2.1.4610-Windows-X64' ']'
+ mv -f sonar-scanner-6.2.1.4610-windows-x64 'D:\a\_temp/sonar-scanner-cli-6.2.1.4610-Windows-X64'
Run echo "${RUNNER_TEMP}/sonar-scanner-cli-6.2.1.4610-Windows-X64/bin" >> $GITHUB_PATH
Run ${GITHUB_ACTION_PATH}/scripts/run-sonar-scanner-cli.sh
+ sonar-scanner.bat
18:38:46.518 INFO Scanner configuration file: D:\a\_temp\sonar-scanner-cli-6.2.1.4610-Windows-X64\bin\..\conf\sonar-scanner.properties
18:38:46.534 INFO Project root configuration file: D:\a\cppTest\cppTest\sonar-project.properties
18:38:46.549 INFO SonarScanner CLI 6.2.1.4610
18:38:46.565 INFO Java 17.0.12 Eclipse Adoptium (64-bit)
18:38:46.565 INFO Windows Server 2022 10.0 amd64
18:38:46.581 INFO User cache: C:\Users\runneradmin\.sonar\cache
18:38:52.005 ERROR Error during SonarScanner CLI execution
18:38:52.005 INFO EXECUTION FAILURE
java.lang.IllegalStateException: Failed to get server version
18:38:52.005 INFO Total time: 5.487s
...
Caused by: java.lang.IllegalStateException: Call to URL [***/api/server/version] failed
...
Caused by: java.net.ConnectException: Failed to connect to localhost/[0:0:0:0:0:0:0:1]:9000
...
18:38:52.013 ERROR
18:38:52.013 ERROR Re-run SonarScanner CLI using the -X switch to enable full debug logging.
Error: Process completed with exit code 1.
Post Run SonarSource/sonarcube-scan-action@v4 - Checked
Post Run actions/checkout@v4 - Checked
Complete job - checked
I am sure java.lang.IllegalStateException: Failed to get server version is the issue. How can I get this resolved - what have I possibly failed to setup?
I’m a bit confused. First we have you running analysis on the SonarQube localhost:
And then we have… a GH Action running?
Is it perhaps that you’re inadvertently also triggering the GHA?
Anyway, that ‘Failed to get server version’ error indicates that the GHA isn’t able to talk to your SonarQube instance.
Getting the version is the very first call the scanner makes to the server, and its failing indicates that the sonar.host.url is misconfigured. (Or that there’s a network block between the two…?)
Thanks for the reply. I run the manual SQ server CLI just to verify the setup is appropriate - and the CLI command is working. It is my intention to avoid this method. I am intending for GitHub Actions via push commands. The SONAR_HOST_URL used is http://localhost:9000. This was verified to work using the manual CLI command and I did try updating the GitHub secret several times thinking as you are thinking. (I am assuming whether CLI or GHA, the results are seen at the localhost:9000 - correct???) For clarity, when I do a commit push, I am not running the CLI manually. I am waiting for the completion of the GHA. (I only run the CLI sporadically to test settings.)
I have tried looking at network settings - no blocked sites.
I even tried disabling the firewall. Network debugging is not my strong point so any pointers or links would be helpful.
Honestly, I don’t know - GitHub?
I just followed the instructions from the localhost:9000 set up analysis in your favorite CI - With GitHub Actions - Analyze your project with GitHub CI.
This has me adding SONAR_TOKEN and SOANR_HOST_URL GitHub secrets as well as making .github/workflows/build.yml and sonar-project.properties files. localhost:9000/tutorials?id=...&selectedTutorial=github-actions
I know if I do a git push, it tries to do an evaluation on the committed code but obviously fails because it cannot read the server version.
Okay, this is the problem. localhost:9000 only works if you’re running analysis on the same box SonarQube is hosted on. If it’s running anywhere else, you’ll need to provide a “from outside” address to your box. Because for GitHub, localhost is… GitHub.
Sorry for the confusion but why does the GitHub CI setup process want to setup SONAR_HOST_URL secret in GitHub to http://localhost:9000?
And where exactly would I setup this localhost of GitHub? What exactly would that look like? GiiHub SONAR_HOST_URL secret of https://github.com/?
Thanks for letting me test your patience!!
I have not seen any wizard to help setup the Server Base URL as of yet. (Be it known I have tried a few Server base URL options such as http://localhost:9000, https://github.com/, blank - all the same results.)
What I am starting to sense is that the localhost:9000 helps are not exactly helpful but more confusing.
I installed a couple SQ zip files on the C: drive - locally on a laptop.
Based on this, I am sensing I can ONLY do a manual CLI for code analysis.
While this option allows for the existence of localhost:9000 results, localhost:9000 will throw out helps but are not necessarily based on the current setup you have already created - leading to confusion for newbies.
If I want to take advantage of the GHA of a commit push, I need to re-install the zips on a ‘server’ and use that URL for the Server Base URL and the GHA.
First, there are no wizards for instance configuration.
Log in as an admin (the default creds are admin/admin, but you were prompted to change the password). Then click on Administration. Do a find in page for ‘base’ and update the Server base URL.
Or, yes, you can install on a “server”, but you may need to request a new license key for your evaluation.
Again, thanks - as you have stated, I have logged in and created a new PW. I have then updated Administration/General/General/Server base URL with differing options:
http://localhost:9000
https://github.com/<myrepo> // with the SonarQ app installed
left it blank
All have the same results - Failed to get server version. I am at a loss of what to put here!!
Not sure if this matters but for the Github app setup, I have:
Forgive my ignorance here but are you asking me that it I can see localhost:9000 on my development laptop, the laptop with SQ Server installed, how would I see localhost:9000 from my other work laptop? If this is the case, currently I have no idea!!
If this is incorrect, could you explain what you mean?
If you want GitHub and SonarQube to interact, then GitHub needs to be able to see your SonarQube instance; it has to be exposed to the internet.
This exactly! You can’t see one machine’s ‘localhost’ from another machine because ‘localhost’ is a self-reference. I.e. it’s the computer equivalent of the pronoun “me”.
So, is your SonarQube instance on your localhost exposed to the internet?
So, it appears that if you have SQ Server running on a local laptop, localhost:9000 is not exposed to the ‘outside’ network. Trying to setup SONAR_HOST_URLs such as http://localhost:9000 or http://<ipv4_addr>:9000/ to allow for GitHub Actions of git push will not work. There needs to be firewall access for Github to get to your local laptop and this could be an IT nightmare for companies with security concerns.
For evaluation purposes, manual analysis with CLI is the best option.
To have it do code analysis based on GitHub Actions such as a git push, it is best to set it up on an actual server.
In other words, don’t try to setup GitHub Actions with evaluation of SQ Server on a local laptop!!