Get the App
SLTechnology News&Howtos  ›  Internet Technology  › 

How to integrate SonarQube with Jenkins

Shulou Source: shulou.com Published: 2022-06-01 09:24:04 09月26日 Update

This article mainly shows you "Jenkins how to integrate SonarQube", the content is easy to understand, clear, hope to help you solve your doubts, the following let the editor lead you to study and learn "Jenkins how to integrate SonarQube" this article.

Jenkins integrates SonarQube Scanner1. Install Jenkins

Download the installation package. Here we download the war package: https://jenkins.io/download/

There are two ways to run jenkins.war:

First: put it in tomcat to run (put it in the webapps directory, start tomcat)

The second kind: execute java-jar jenkins.war-httpPort=8080 directly

Third: Docker deployment:

# View jenkins version command docker search jenkins# pull image command (not marked for the latest) the mount directory of docker pull jenkins# article is the permission to modify mkdir / home/jenkins# under home (1000 home is UID and GID) key: this directory needs to set permissions Otherwise, boot container error permissions chown-R 1000 home/jenkins:/var/jenkins_home 1000 / home/jenkins/# use image boot container command docker run-d-p 8000 docker run 8080-p 50000 docker run 50000-v / boot-- name jenkins-- privileged=true-u root jenkins

Https://jenkins.io/doc/pipeline/tour/getting-started/

Here we choose the first way.

Start tomcat (bin/startup.sh) to access http://localhost:8080/jenkins/

The Jenkins installation is complete.

two。 Install the SonarQube Scanner plug-in

Configure SonarQube after installation is complete

Generate a Token in SonarQube (PS: use token instead of entering a user name and password). Under "my account" and "Security" under the user's profile picture, generate token.

Then configure the address in Jenkins to connect to the sonarqube server. The token used here is the token you just created in sonarqube.

Set the token of SonarQube servers in the system configuration in Jenkins

Install SonarQube servers in the global configuration in Jenkins

3. Create a task

Configure the configuration of SVN or GIT

Most importantly, configure SonarQube analysis properties

You can write it separately in a configuration file (sonar-project.properties), or you can write it every time like this.

Sonar.projectKey=$ {JOB_NAME} sonar.sources=.sonar.projectName=$ {JOB_NAME} sonar.projectVersion=$ {BUILD_VERSION} sonar.language=javasonar.sourceEncoding=UTF-8sonar.sources=$WORKSPACEsonar.java.binaries=$WORKSPACE above is all the content of this article "how Jenkins integrates SonarQube". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!

Tags: Configuration content command method permissions directory article container mirror learning help run important security task global address password that is account Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Linux MariaDB Huawei Shulou Technology OPPO Reno