How to build sonarqube using docker

How to build sonarqube using docker

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 Docker

After the installation is complete, enter the command line

docker -v

When the version number appears, the installation is complete.

. . . . . . . .

2. Install sonar image

1. 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 code

After 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:
  • Docker builds the code detection platform SonarQube and detects the process of Maven projects

<<:  Repair solution for inconsistent MySQL GTID master and slave

>>:  JavaScript Composition and Inheritance Explained

Recommend

MySQL 8.0.14 installation and configuration method graphic tutorial

This article records the installation and configu...

Ubuntu 20.04 turns on hidden recording noise reduction function (recommended)

Recently, when using kazam in Ubuntu 20.04 for re...

A brief discussion on the whole process of Vue's first rendering

Table of contents 1. Vue initialization vue entry...

Calling Baidu Map to obtain longitude and latitude in Vue

In the project, it is necessary to obtain the lat...

Mysql solution to improve the efficiency of copying large data tables

Preface This article mainly introduces the releva...

Summary of Common Commands for Getting Started with MySQL Database Basics

This article uses examples to describe the common...

How to set up automatic daily database backup in Linux

This article takes Centos7.6 system and Oracle11g...

Steps to customize icon in Vue

ant-design-vue customizes the use of Ali iconfont...

Summary of common tool functions necessary for front-end development

1. Time formatting and other methods It is recomm...

Teach you to implement a simple promise step by step

Table of contents Step 1: Build the framework Ste...

Detailed steps for installing and using vmware esxi6.5

Table of contents Introduction Architecture Advan...

Detailed explanation of Linux curl form login or submission and cookie usage

Preface This article mainly explains how to imple...

Detailed installation and use tutorial of mysql 8.0.15 under windows

This article shares with you the detailed install...

MySQL 5.7.17 installation and configuration graphic tutorial

Features of MySQL: MySQL is a relational database...