[Docker implements test deployment CI/CD----Jenkins integration related servers (3)]

7. Jenkins integrates SonarQube

Install SonarScanner in Jenkins

        SonarScanner It is a code scanning tool specifically used to scan and analyze project code quality. After scanning and analysis are completed, the results will be written to the database of the SonarQube server and the data will be displayed on the SonarQube platform.

download

        SonarScanner can be downloaded from the help documentation on the SonarQube official website. Download a version for Linux systems here. portal

[root@jenkins opt]# wget https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-4.8.0.2856-linux.zip

decompress

[root@jenkins opt]# unzip sonar-scanner-cli-4.8.0.2856-linux.zip 

move

        To integrate SonarScanner in Jenkins , SonarScanner needs to exist in the data volume directory in the Jenkins server. So move the decompressed directory to the data volume jenkins_home and rename it to sonar-scanner

[root@jenkins opt]# mv sonar-scanner-4.8.0.2856-linux /var/jenkins_home/sonar-scanner

Modify configuration file

There is its configuration file sonar-scanner.properties in the conf directory of the sonar-scanner directory.

[root@jenkins conf]# vim sonar-scanner.properties 
#----- Default SonarQube server
#sonar.host.url=http://localhost:9000
sonar.host.url=http://192.168.40.172:9000
#----- Default source code encoding
sonar.sourceEncoding=UTF-8
#项目的工作目录
sonar.sources=./ 
sonar.java.binaries=./target

8. Jenkins configures SonarQube

Install plugin

Jenkins 页面的系统管理 ->插件管理 ->Available pluginsSearch in         to sonarqube scannerinstall the plugin. This plugin is used to connect SonarScanner.
Insert image description here

Restart after the installation is complete

AddSonarQube

Insert image description here

First configure the Name and Server URL, then save and exit. Then you can see Jenkins.

Insert image description here

The username and password are the username and password of jenkins

Insert image description here

Click Apply, Save, and Exit

AddSonarScanner

        Configure the SonarScanner previously installed in the Jenkins data volume into Jenkins. 在 Jenkins 页面的 Manage Jenkins ->全局工具配置 中找到 SonarQube Scanner.

Insert image description here

9. Jenkins integrated target server

        Here you need to configure the connection method to connect to the target server. Open Manage Jenkins 中的 Configure System 页面.

Insert image description here

Insert image description here

Guess you like

Origin blog.csdn.net/qq_52589631/article/details/132072133