Issue while integrating SonarQube with GitLab

Hi Team,

Good morning!! I’m facing below error while trying to perform node.js sample code quality check through SonarQube. My source code and pipeline are configured in GitLab. The SonarQube I’m using community SonarQube version 10.5.1. I already set the Project Key, Login token, Sonar host url parameters in place.

Login to server is succeeding with my account later job is failing with
Error: “GET /sonarqube/api/v2/analysis/version HTTP/1.1” 404 - “-” “axios/1.6.8”

Could you please help out with this issue resolution. Thank you for the support in advance.

Hi,

Welcome to the community!

This is the first call the Scanner makes to the server. If it’s failing, then your sonar.host.url is misconfigured. What happens when you try to manually access the URL?

 
Ann

I’m able to access the url manually it’s routing to the repo in the sonarqube instance as expected.

P.S. in our sonarqube instance under permission template “Execute Analysis” option is not checked does it need to be checked ?

Hi,

When you access the api/v2/analysis/version path, you’re routed to the project in SonarQube?! That’s… wrong.

If you were getting a different kind of error, I’d say this might be related, but a 404 at this stage in analysis is unrelated to that.

 
Ann

We are not using the sonar image. We just installed sonar-scanner packages on our alpine image below are the logs can you have a check and let me know the steps for resolution

[INFO]  Bootstrapper: Retrieving info from "package.json" file
[DEBUG] Bootstrapper: Setting the log level to DEBUG due to verbose mode
[DEBUG] Bootstrapper: Properties: {
  'sonar.userHome': '/root/.sonar',
  'sonar.scanner.os': 'alpine',
  'sonar.scanner.arch': 'x64',
  'sonar.exclusions': 'node_modules/**,bower_components/**,jspm_packages/**,typings/**,lib-cov/**',
  'sonar.projectKey': 'XXXX-XXXX',
  'sonar.projectName': 'XXXX-XXXX',
  'sonar.projectVersion': '0.0.1',
  'sonar.qualitygate.wait': 'true',
  'sonar.token': '[MASKED]',
  'sonar.host.url': '//xxxxx/sonarqube',
  'sonar.verbose': 'true',
  'sonar.login': '[MASKED]',
  'sonar.sources': '/xxxx/xxxx/xxx/nest-hello-world-master/src/',
  'sonar.scanner.internal.isSonarCloud': 'false',
  'sonar.scanner.apiBaseUrl': 'xxxxxxx/sonarqube/api/v2',
  'sonar.scanner.app': 'ScannerNpm',
  'sonar.scanner.appVersion': '4.0.1',
  'sonar.scanner.bootstrapStartTime': '1718118731707',
  'sonar.scanner.wasJreCacheHit': 'disabled',
  'sonar.scanner.wasEngineCacheHit': 'false',
  'sonar.projectBaseDir': '/xxxxx/xxxx/xxxx/nest-hello-world-master'
}
[INFO]  Bootstrapper: Platform: alpine x64
[DEBUG] Bootstrapper: Detecting proxy: No proxy detected
[INFO]  Bootstrapper: Server URL: //xxxxxxx/sonarqube
[INFO]  Bootstrapper: Version: 4.0.1
[DEBUG] Bootstrapper: Check if Server supports JRE provisioning
[DEBUG] Bootstrapper: Detecting SonarQube server version
[DEBUG] Bootstrapper: Fetching API V2 /analysis/version
[DEBUG] Bootstrapper: Unable to fetch API V2 /analysis/version: AxiosError: Request failed with status code 404. Falling back on /api/server/version
[DEBUG] Bootstrapper: Not using axios instance for ://xxxxxxx/sonarqube/api/server/version
[INFO]  Bootstrapper: SonarQube server version: 10.5.1
[DEBUG] Bootstrapper: SonarQube Server v10.5.1 supports JRE provisioning: false
[INFO]  Bootstrapper: JRE provisioning is NOT supported
[INFO]  Bootstrapper: Falling back on using sonar-scanner-cli
[INFO]  Bootstrapper: Downloading SonarScanner CLI
[DEBUG] Bootstrapper: Downloading from
[DEBUG] Bootstrapper: Downloading 
[DEBUG] Bootstrapper: Not using axios instance for 
[ERROR] Bootstrapper: An error occurred: AxiosError: Request failed with status code 400

Hi,

Which scanner are you using? Can we have the full analysis log, starting from the analysis command?

The analysis / scanner log is what’s output from the analysis command. Hopefully, the log you provide - redacted as necessary - will include that command as well.

This guide will help you find them.

 
Thx,
Ann