I integrated SonarQube with Azure DevOps. Created a pipeline and added ‘Prepare SonarQube analysis’ task in the pipeline. But the task fails with the below error. I have followed all the steps of integration and SonarQube server is running. The error pipeline generates is as follows:
##[error][SQ] API GET ‘/api/server/version’ failed, error was: {“errno”:“ECONNREFUSED”,“code”:“ECONNREFUSED”,“syscall”:“connect”,“address”:“127.0.0.1”,“port”:9000}
I suggest taking the task out of the equation entirely and querying localhost:9000/api/sever/version via a curl or Invoke-WebRequest in the context of your pipeline to see if you also get a refused connection.
I get an error ’ SonarQube server [http://localhost:9000] can not be reached’ with the Invoke-WebRequest on my pipeline.
My SonarQube server is up and running and I am able to access the dashboard.
It sounds like maybe you have Azure DevOps and SonarQube installed on the same server, but an Azure DevOps build agent installed separately. Is that possible?
That’s certainly one way to address it (you’ll have to refer to Azure DevOps docs and support) – and, more commonly, you would expose your SonarQube server hosted on port 9000 to the internet (or at least to other resources on your intranet) so that it can be accessed by many build agents, and users not just on the machine it’s hosted.