Not sure what is up with your extension but it does not work that well in Azure DevOPS

I have been tailing both NGNIX logs and SonarQube. The behavior I am seeing is one moment it connects and works the next pipeline run it either works or fails. I can not get to work with any kind of constancy. My SonarQube Developer VM is in Azure Portal. I have added a rule to allow the traffic through from a service tag of AzureCloud which should let the traffic through. Durring the SonarQube prepare step sometimes it can get to api/version sometimes not. Mostly it can not get there and the pipeline fails.

This makes it hard to setup a scan for our React Mobile application for iOS and Android since I can not have the pipeline failing ever other try.

I have tried to use a self-hosted agent proxying the connection. That lead to other issue with regards to Python and Java being found on the Mac Mini in our office. We are trying to use the latest Mac OSX agent in Azure DevOPS. I have also tried windows with the same issues.

I have learned that the other groups are not using your sonarQubePrepare@5 extension.* So now am curious about if it is something with that version of this extension.

Other groups are using these PowerShell commands instead.

`$QualityGateResult = Invoke-WebRequest -Uri “https://$(sonarServerName)/api/qualitygates/project_status?projectKey=$(sonarqube_projectkey)” -Method GET -Headers $headers -ErrorAction Stop -Verbose

if ($QualityGateResult.Content.Contains(‘“projectStatus”:{“status”:“OK”’)){
Write-Host (“SonarQube scan passed Quality Gate!!!”) -ForegroundColor Green
}

else
{
throw “Quality gate failed. Please check and fix the issues. Quality gates status can be viewed on SonarQube Server.”
}`

This seems to work all the time. I will be trying this with my YAML pipeline next.

So this call does not try to speak to api/version whereas the extension is the 1st thing it does. This call works sometimes and other times it does not. I have added this rule into the NSG that Sonarqube uses:

This rule lets the service tag of AzureCloud through for connection to the ports in the middle here 443, 8443, 8080, 80, 9090, 9000.

I have also tested this solution by doing a curl in a pipeline:

This gave me a 200 response which is what I would expect for an HTTP response from your API.

Unsure if anyone else has run into this. Also we are on latest SonarQube developer version if this helps which is 10.4

Thanks,
Nick

Hey there.

I would suggest first trying to isolate the issue to the extension or more generally the network connectivity between your agent and SonarQube.

In a pipeline using the extension that often fails, you could try adding a command (curl or Invoke-WebRequest) to <sonarqube_url>/api/server/verison (the same URL the extension is calling) and see if URL request fails as well, or if only the extension fails.

If the URL request also fails (without the extension), we know it’s a network connectivity issue. If it works, but the extension fails to call the same URL, we know it’s an issue with the extension.

Even this works off and on… CURL works one minute next run it does not work. I have turned verbose on in sonarqube I am not seeing anything is very odd

Well, if you never have trouble hitting it from your browser but the problem only comes when using the build agent, it sounds like there’s a connectivity problem between those two resources.