Welcome to the Linux Foundation Forum!

Issue with SonarQube integration in Jenkins

Options
stefanvlad27
stefanvlad27 Posts: 1
edited July 2023 in LFS261 Class Forum

Hello,

I'm currently attempting to integrate code scanning from my repository using SonarScanner in Jenkins. Here's the current setup:

Within Jenkins, I have the "SonarQube Scanner for Jenkins" plugin installed, and the SonarQube server and its credentials properly configured in the System Configuration section. I've also marked the option to install the SonarScanner through Jenkins.

Regarding the Jenkins project, it is set up as a "Freestyle project." In the project's configuration, the "Source Code Management" section is set to "git" pointing to my repository (https://github.com/StefanVlad27/prueba_svlad.git). The rest of the configuration is set to default, except for the "Build steps" section, where there is an action for "Execute SonarQube scanner" with only the name specified.

Additionally, it's worth mentioning that my Git repository contains a sonar-project.properties file, which SonarScanner uses to retrieve the configuration.

On the surface, this configuration appears to be correct, and I've followed the official guides. However, when I run Jenkins, I encounter the following output:

Started by user Stefan Vlad
Running as SYSTEM
Building in workspace /var/lib/jenkins/workspace/prueba-freestyle
The recommended git tool is: NONE
No credentials specified

git rev-parse --resolve-git-dir /var/lib/jenkins/workspace/prueba-freestyle/.git # timeout=10

Fetching changes from the remote Git repository

git config remote.origin.url https://github.com/StefanVlad27/prueba_svlad.git # timeout=10

Fetching upstream changes from https://github.com/StefanVlad27/prueba_svlad.git

git --version # timeout=10
git --version # 'git version 2.34.1'
git fetch --tags --force --progress -- https://github.com/StefanVlad27/prueba_svlad.git +refs/heads/:refs/remotes/origin/ # timeout=10
git rev-parse refs/remotes/origin/main^{commit} # timeout=10

Checking out Revision 942e61db4cd551d49468b6c5366880eff9e1af3c (refs/remotes/origin/main)

git config core.sparsecheckout # timeout=10
git checkout -f 942e61db4cd551d49468b6c5366880eff9e1af3c # timeout=10

Commit message: "Update sonar-project.properties"

git rev-list --no-walk 307fdffdfb12dc824369a90451d977747eb2ccda # timeout=10

[prueba-freestyle] $ /var/lib/jenkins/tools/hudson.plugins.sonar.SonarRunnerInstallation/Sonnar-scanner-install/bin/sonar-scanner sonnar-scan1 -X -Dsonar.host.url=http://arq9-alb-886148692.eu-west-1.elb.amazonaws.com:9000/ ******** -Dsonar.projectBaseDir=/var/lib/jenkins/workspace/prueba-freestyle
13:48:11.355 INFO: Scanner configuration file: /var/lib/jenkins/tools/hudson.plugins.sonar.SonarRunnerInstallation/Sonnar-scanner-install/conf/sonar-scanner.properties
13:48:11.360 INFO: Project root configuration file: /var/lib/jenkins/workspace/prueba-freestyle/sonar-project.properties
13:48:11.421 INFO: SonarScanner 4.8.0.2856
13:48:11.422 INFO: Java 17.0.7 Private Build (64-bit)
13:48:11.422 INFO: Linux 5.19.0-1028-aws amd64
13:48:11.674 DEBUG: keyStore is :
13:48:11.674 DEBUG: keyStore type is : pkcs12
13:48:11.674 DEBUG: keyStore provider is :
13:48:11.674 DEBUG: init keystore
13:48:11.674 DEBUG: init keymanager of type SunX509
13:48:11.802 DEBUG: Create: /var/lib/jenkins/.sonar/cache
13:48:11.803 INFO: User cache: /var/lib/jenkins/.sonar/cache
13:48:11.803 DEBUG: Create: /var/lib/jenkins/.sonar/cache/_tmp
13:48:11.805 DEBUG: Extract sonar-scanner-api-batch in temp...
13:48:11.809 DEBUG: Get bootstrap index...
13:48:11.809 DEBUG: Download: http://arq9-alb-886148692.eu-west-1.elb.amazonaws.com:9000/batch/index
13:48:11.873 DEBUG: Get bootstrap completed
13:48:11.876 DEBUG: Create isolated classloader...
13:48:11.896 DEBUG: Start temp cleaning...
13:48:11.899 DEBUG: Temp cleaning done
13:48:11.899 DEBUG: Execution getVersion
13:48:11.912 INFO: Analyzing on SonarQube server 9.9.1.69595
13:48:11.913 DEBUG: Execution execute
13:48:12.258 DEBUG: Community 9.9.1.69595
13:48:12.523 INFO: Load global settings
13:48:12.575 DEBUG: GET 200 http://arq9-alb-886148692.eu-west-1.elb.amazonaws.com:9000/api/settings/values.protobuf | time=50ms
13:48:12.612 INFO: Load global settings (done) | time=89ms
13:48:12.615 INFO: Server id: 86E1FA4D-AYkhTBas4owBNcLPG1Rt
13:48:12.621 INFO: User cache: /var/lib/jenkins/.sonar/cache
13:48:12.624 INFO: Load/download plugins
13:48:12.624 INFO: Load plugins index
13:48:12.632 DEBUG: GET 200 http://arq9-alb-886148692.eu-west-1.elb.amazonaws.com:9000/api/plugins/installed | time=8ms
13:48:12.668 INFO: Load plugins index (done) | time=44ms
13:48:12.742 INFO: Load/download plugins (done) | time=118ms
13:48:12.824 DEBUG: Plugins:
13:48:12.824 DEBUG: * Python Code Quality and Security 3.24.0.10784 (python)
13:48:12.824 DEBUG: * Go Code Quality and Security 1.11.0.3905 (go)
13:48:12.825 DEBUG: * JaCoCo 1.3.0.1538 (jacoco)
13:48:12.825 DEBUG: * Kotlin Code Quality and Security 2.12.0.1956 (kotlin)
13:48:12.826 DEBUG: * IaC Code Quality and Security 1.11.0.2847 (iac)
13:48:12.826 DEBUG: * JavaScript/TypeScript/CSS Code Quality and Security 9.13.0.20537 (javascript)
13:48:12.826 DEBUG: * Ruby Code Quality and Security 1.11.0.3905 (ruby)
13:48:12.826 DEBUG: * SQL language plugin 1.2.0 (sql)
13:48:12.827 DEBUG: * Scala Code Quality and Security 1.11.0.3905 (sonarscala)
13:48:12.827 DEBUG: * C# Code Quality and Security 8.51.0.59060 (csharp)
13:48:12.827 DEBUG: * Java Code Quality and Security 7.16.0.30901 (java)
13:48:12.827 DEBUG: * HTML Code Quality and Security 3.7.1.3306 (web)
13:48:12.827 DEBUG: * Flex Code Quality and Security 2.8.0.3166 (flex)
13:48:12.828 DEBUG: * XML Code Quality and Security 2.7.0.3820 (xml)
13:48:12.828 DEBUG: * PHP Code Quality and Security 3.27.1.9352 (php)
13:48:12.828 DEBUG: * Text Code Quality and Security 2.0.2.1090 (text)
13:48:12.828 DEBUG: * VB.NET Code Quality and Security 8.51.0.59060 (vbnet)
13:48:12.828 DEBUG: * Configuration detection fot Code Quality and Security 1.2.0.267 (config)
13:48:12.902 INFO: ------------------------------------------------------------------------
13:48:12.903 INFO: EXECUTION FAILURE
13:48:12.903 INFO: ------------------------------------------------------------------------
13:48:12.904 INFO: Total time: 1.594s
13:48:12.922 INFO: Final Memory: 6M/27M
13:48:12.922 INFO: ------------------------------------------------------------------------
13:48:12.922 ERROR: Error during SonarScanner execution
Tasks support was removed in SonarQube 7.6.
WARN: Unable to locate 'report-task.txt' in the workspace. Did the SonarScanner succeed?
ERROR: SonarQube scanner exited with non-zero code: 2
Finished: FAILURE

If you require any additional information, please don't hesitate to ask.

Thank you for your assistance.

EDIT: Please note that the repository mentioned above is a testing repository, and the code provided consists of random open-source files.

Comments

Categories

Upcoming Training