What is the implementation code testing process of jenkins and sonar?
This article is about how the code testing process of jenkins and sonar implementation is like. The editor thinks it is very practical, so share it with you as a reference and follow the editor to have a look.
First, install the client of sonar scanner
My jenkins version is 2.176.2
To install sonar, you need to install the client and the server. Here we only describe the relevant configuration of the client. Installation steps are omitted
Second, then configure the environment variables of sonar scanner
Edit the server's profile file
Vim / etc/profile, add environment variables
Export MAVEN_HOME=/opt/servers/apache-maven-3.6.1export SONAR_SCANNER_HOME=/opt/sonar-scanner
Third, first install the plug-ins required by jenkins
4. Configure configuration of SonarQube servers
Here, you need to configure the address and account of the sonar server, because my version only provides token, and token needs to be obtained from the sonnar server. The specific way needs to be found separately.
Note: there are only ip and port behind the url here, but no / sonar, otherwise an error will be reported when configuring job later.
Configure the global configuration of sonar
Create a job and add the configuration information of the sonar scanner
First of all, you need to check here to indicate that the code is checked before the code is built.
Create the first task in job, create Execute SonarQube Scanner
Fill in the property information in the pop-up form
The properties here overwrites the sonar-project.properties file in the project by default, so after you configure it here, you don't need to add files to the project.
Thank you for reading! On "jenkins and sonar code testing process is how" this article is shared here, I hope the above content can be of some help to you, so that you can learn more knowledge, if you think the article is good, you can share it out for more people to see it!