Sonarqube is a code quality checking tool. Using sonar to scan the code we have written can help check the bugs, standardization and robustness of the code, which helps to improve the quality of our code. 1. Install DockerAfter the installation is complete, enter the command line docker -v When the version number appears, the installation is complete. . . . . . . . . 2. Install sonar image1. Enter in the command line docker -search sonar You will see many sonar versions: 2. We use the command directly, docker pull sonar downloads the latest version of sonarqube by default docker pull sonar After the download is complete, execute docker images to view the downloaded image files. Already have sonarqube. 3. Run sonar Command line input docker run -p9000:9000 sonarqube The default port of sonar is 9000. Map the port 9000 in the docker image to the host port 9000. At this time, we open the browser and enter the URL localhost:9000 to enter the docker page. The default login account and password are both admin. At this point, our sonar installation and operation is complete. 4. Persistent Sonar If you need to persist our sonar scan data, you can use the following command to start sonar. The jdbc information is the mysql connection, username and password. Sonar will persist the scan information to MySQL. docker run --restart=always -d --name sonarqube \ -p 9000:9000 \ -e sonar.jdbc.username=root \ -e sonar.jdbc.password=123456 \ -e sonar.jdbc.url= jdbc:mysql://172.30.50.215:3306/payment?useUnicode=true&characterEncoding=UTF-8 \sonarqube 3. Use sonar to scan codeAfter logging in to the sonar page, click to create a project Click manually. You can also select GitHub here. Using git to associate sonar with your project makes it easier to scan code branches. Then enter a project name at random. It is recommended to make it the same as the project name. Enter anything (it is recommended to be the same as the project name) to generate a token. After generation, click continue. Choose maven or gradle, or others according to our project location. Sonar will automatically give the command to scan the code below. Then open our idea and execute it in the command line below. There is a pitfall here. Since sonar will scan our class files in the target directory, we need to package the project first. mvn -package Then scan again. After the scan is complete, return to localhost:9000 and you can see the quality problems in our code. Note: The latest version (5.7 and above) of SonarQube no longer supports MySQL. It is recommended to use other databases or use version 5.2 This is the end of this article about how to use docker to build sonarqube. For more information about building sonarqube with docker, please search for previous articles on 123WORDPRESS.COM or continue to browse the following related articles. I hope you will support 123WORDPRESS.COM in the future! You may also be interested in:
|
<<: Repair solution for inconsistent MySQL GTID master and slave
>>: JavaScript Composition and Inheritance Explained
1. Overview The Promise object is a specification...
Copy code The code is as follows: <html> &l...
1. Installation steps for MySQL 8.0.12 version. 1...
1. Concept 1. The difference between hot backup a...
<meta name="viewport" content="w...
Table of contents Overview 1. RangeError 2. Refer...
<br />Previously, we learned how to set cell...
Table of contents Preface Core code File shows pa...
<br />Table is a tag that has been used by e...
This article shares the specific code of canvas t...
Nginx can generally be used for seven-layer load ...
Think about it: Why should css be placed in the h...
As a tester, you may often need to install some s...
clip-path CSS properties use clipping to create t...
This time, we will try to package the running con...