SonarQube preparation task fails with no error message

I am experiencing some strange issues with our self-hosted SonarQube instance in an Azure yml pipeline.

I have added the Prepare Analysis Configuration in my .yml pipeline using a ubuntu-latest vmImage.

- task: SonarQubePrepare@6
  inputs:
    SonarQube: 'SonarQube'
    scannerMode: 'MSBuild'
    projectKey: 'deleted'

I have set up the Service connection with Read& Write access to the repository and followed the steps in the docs on connecting to the pipeline but when running it, I get the following error (or lack thereof):

##[warning]Error while executing SonarQube:Prepare task: [SQ] API GET ‘/api/server/version’ failed, error is The operation was aborted.

I’ve done this setup before with SonarCloud and it worked without a hitch so I’m wondering if it is not something to do with the self-hosted setup. I don’t have access to the deployment but I can share that there is no reverse proxy, it is deployed on a VM in Azure alongside a Jenkins instance (which can access SonarQube without any issues.)

I’ve tried setting and resetting the service connection in DevOps, resetting the token, basically trying to eliminate the possibility that I have missed permissions in Azure but I’m a bit stumped due to the lack of an error in the pipeline. I haven’t tried using a self-hosted version before so I’m not sure if maybe networking is getting in the way here :slight_smile:

I have gotten some of the logs from the server and can see that the access.log is being spammed by my project:

10.0.0.162 - - [02/Sep/2024:15:43:30 +0200] “GET /api/ce/component?component=myProjectKey HTTP/1.1” 200 - “http://myhostUrl:portno/api/server/version/tutorials?id=myProjectKey&selectedTutorial=azure-pipelines” “Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/128.0.0.0 Safari/537.36” “key”

I can also see the service connection in Azure being accessed as well.

I’m tempted to point fingers at the HTTP call or the lack of a reverse proxy, but I am not sure if I’m headed in the right direction, since the log shows a lot of undefined fields. Any pointers are highly appreciated.

Full debug mode on the pipeline (edited out the URLs and keys):


##[debug]loading ENDPOINT_AUTH_PARAMETER_myGuid_USERNAME
##[debug]loading ENDPOINT_AUTH_SYSTEMVSSCONNECTION
##[debug]loading ENDPOINT_AUTH_SCHEME_SYSTEMVSSCONNECTION
##[debug]loading ENDPOINT_AUTH_PARAMETER_SYSTEMVSSCONNECTION_ACCESSTOKEN
##[debug]loading SECRET_SYSTEM_ACCESSTOKEN
##[debug]loaded 16
##[debug]Agent.ProxyUrl=undefined
##[debug]Agent.CAInfo=undefined
##[debug]Agent.ClientCert=undefined
##[debug]Agent.SkipCertValidation=undefined
##[debug]Agent.ProxyUrl=undefined
##[debug]Agent.CAInfo=undefined
##[debug]Agent.ClientCert=undefined
##[debug]check path : /home/vsts/work/_tasks/SonarQubePrepare_guid/6.3.2/lib.json
##[debug]adding resource file: /home/vsts/work/_tasks/SonarQubePrepare_guid/6.3.2/lib.json
##[debug]system.culture=en-US
##[debug]SonarQube=removed
##[debug]myGuid=http://myhostUrl:portno/
##[debug]myGuid auth param apitoken = undefined
##[debug]myGuid auth param username = ***
##[debug]myGuid auth param password = undefined
##[debug]organization=undefined
##[debug]scannerMode=MSBuild
##[debug]projectKey=myProjectKeyFromSonar
##[debug]projectName=undefined
##[debug]projectVersion=1.0
##[debug]organization=undefined
##[debug][SQ] API GET: '/api/server/version' with full URL "http://myhostUrl:portno/api/server/version" and query "undefined"
##[debug]Not using a proxy agent
##[debug][SQ] API GET '/api/server/version' failed, error is The operation was aborted.
##[warning]Error while executing SonarQube:Prepare task: [SQ] API GET '/api/server/version' failed, error is The operation was aborted.
##[debug]Processed: ##vso[task.issue type=warning;]Error while executing SonarQube:Prepare task: [SQ] API GET '/api/server/version' failed, error is The operation was aborted.
##[debug]task result: Failed
##[error][SQ] API GET '/api/server/version' failed, error is The operation was aborted.
##[debug]Processed: ##vso[task.issue type=error;][SQ] API GET '/api/server/version' failed, error is The operation was aborted.
##[debug]Processed: ##vso[task.complete result=Failed;][SQ] API GET '/api/server/version' failed, error is The operation was aborted.

Hey there.

This looks awfully similar to this post:

I know a developer recently pinged that post to look at a potential regression in a library used by the scanner.

Are you sure your SQ server is accessible from your build agent? If you execute a curl http://myhostUrl:portno/api/server/version from your build pipeline, do you get the expected results?

Hi Colin!

Thanks for the reply - you are right, it does look similar. It didn’t pop up when I was searching for potential solutions.
I’ve added the curl to the pipeline before the preparation task:

- task: CmdLine@2
  displayName: Curl Check
  inputs:
    script: 'curl http://myhostUrl:portno/api/server/version

The request times out after 120s. I will ask for some logs on the server, but based on the previous logs I received, I doubt there will be anything. The server setup and deployment is a black box, but I can reach out to a different team for some answers.

To answer your question, I am not sure that the server is accessible which was the reason for posting this. I’ve tried doing this with SonarCloud before, but never with a hosted SonarQube. Is it the http? Is it the lack of a reverse proxy? Is it in the VS Marketplace package? Is it something else in the connection/setup?

SonarQube is a web application (like any other website you visit) and must be available on the network to other machines that want to communicate with it. In an internal (corporate) network, that typically means asking your Server Admins to open up certain ports so that it is accessible by other machines.