Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Jenkins integrated SonarQube Scanner

2025-03-26 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/03 Report--

1. Install the plug-in in jenkins: SonarQube Scanner

2. Install the SonarQube Scanner parts on the jenkins host and under the jenkins user

Cd / usr/local

Unzip sonar-scanner-cli-4.2.0.1873-linux.zip

Ln-s sonar-scanner-4.2.0.1873-linux sonar-scanner

Chown-R jenkins: sonar-scanner-4.2.0.1873-linux

Echo 'export SONAR_SCANNER_HOME=/usr/local/sonar-scanner' > > / etc/profile

Echo 'export PATH=$SONAR_SCANNER_HOME/bin:$PATH' > > / etc/profile

Source / etc/profile

Vim conf/sonar-scanner.properties

Sonar-scanner-h

3. Integrate Jenkins and SonarQube: Web login jenkins, system management, global tool configuration, SonarQube Scanner, and configure the installed sonar-scanner.

Log in to sonar on the web page to create token

Log in to the web page with jenkins, credentials, jenkins, global credentials, add credentials, Secret text type, and enter the token in the previous step

Log in to jenkins, system Administration, system Settings, SonarQube servers, configuration name and url, and select the credentials added in the previous step.

4. Configure Jenkins tasks

Task to run: enter scan, that is, the analysis code

JDK: select the JDK used by SonarQube Scanner (note that it must be JDK, not JRE)

Path to project properties: you can specify a sonar-project.properties file here. If not, the project default properties file will be used.

Analysis properties: here you need to enter some configuration parameters to pass to SonarQube. The parameters here take precedence over the parameters in the sonar-project.properties file, so you can configure all the parameters here to replace the sonar-project.properties file. Some parameters are listed below, and sonar.language specifies the development language to be analyzed (specific development language corresponds to specific rules). Sonar.sources defines the source code location that needs to be analyzed (in the example. Indicating the directory of the current Jenkins project), sonar.java.binaries defines the location of the compiled files that need to analyze the code

You can enter some additional parameters in the Additional arguments input box. The-X in the example means to enter the Debug mode of SonarQube Scanner, which will output more log information.

JVM Options can enter the JVM parameters that are required to execute SonarQube Scanner.

5. Test build

Error message when building the project: Caused by: Please provide compiled classes of your project with sonar.java.binaries property. The problem is that the corresponding class file was not found in the project project scanned by sonar.

Solution: in the Analysis properties project, add the configuration of sonar.java.binaries, which is the path to the compiled .class file in the project.

6. Log in to sonarqube to view

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report