Jenkins + Sonarqube Integrated detection Code Quality

Source: Internet
Author: User

To be perfected, the edge of the environment, side records, there will be missed the possibility, and so have time to tidy up a

Reference:

http://blog.csdn.net/kefengwang/article/details/54377055


Http://www.jianshu.com/p/a8d4825146a6


Prerequisite: The Linux machine has been installed jdk1.8 and Jenkins

Sonarqube Download Address: https://sonarsource.bintray.com/Distribution/sonarqube/sonarqube-6.7.zip



1. Upload to server, decompression: unzip/usr/local/sonarqube-6.7.zip-d/usr/local/

Unzip command not installed, error command not found

Execution: Yum install-y unzip zip

Execute Script/usr/local/sonarqube-6.7/bin/linux-x86-64/sonar.sh

Hint Usage:/usr/local/sonarqube-6.7/bin/linux-x86-64/sonar.sh {Console | start | stop | restart | status | dump}
Start Sonarqube:/usr/local/sonarqube-6.7/bin/linux-x86-64/sonar.sh start

Tips

Starting Sonarqube ...
Started Sonarqube.

Viewing log:/usr/local/sonarqube-6.7/logs/es.log prompts to can not run Elasticsearch as root

Reference: http://blog.csdn.net/gebitan505/article/details/54709515

HTTPS://MY.OSCHINA.NET/TOPEAGLE/BLOG/591451?FROMERR=MZ OR2 Qzz


Create Group: Groupadd Sonarqube

Create users and add to groups: Useradd sonarqube-g sonarqube-p SA***DD


Toggle Normal User: Su-sonarqube

Here is a problem: Authentication failure have no authority, looking for n long

Search on Google: https://stackoverflow.com/questions/47731102/ Cant-run-sonar-server-caused-by-elasticsearch-cannot-running-as-root

Find out from the answer: Https://stackoverflow.com/questions/47731102/cant-run-sonar-server-caused-by-elasticsearch-cannot-running-as-root

Edit/opt/sonarqube/bin/sonar.sh-Find the Run_as_user entry, uncomment it and set it to the user you just created


Last start:/usr/local/sonarqube-6.7/bin/linux-x86-64/sonar.sh start

Through: NETSTAT-NLP can see that port 9000 is open

The description has been started successfully, all 8 points 14, ah 2 hours, just get here, still have to continue to refuel

After changing the port, continue to start discovery and hang again, look at the log found to be caused by:org.h2.jdbc.JdbcSQLException:Connection is broken: "Session closed" [90067-176]

JDBC is not configured sonar.properties

The JDBC connection information is configured and the error is made


vm.max_map_count=655360

At this time found that the machine memory is not enough sonar at least 2G machine to run to 1G and I use the machine also 2G of memory oh my good

Intranet transmission to another Ali cloud machine Scp-r/usr/local/sonarqube-6.7 root@172.***.**.254:/usr/local/

Vi/etc/sysctl.conf

vm.max_map_count=655360

Not enough memory configuration to modify configuration

Viewing restrictions: Ulimit-hn

Vi/etc/security/limits.conf

http://blog.csdn.net/xxxxxx91116/article/details/17136299


Forgot to give permissions to the folder after Chown-r sonarqube/usr/local/sonarqube-6.7


Launch successful, now time 2017-12-18 21:44:36

Go home and get it.


Find the Chinese plug-in: https://github.com/SonarQubeCommunity/sonar-l10n-zh/releases/tag/sonar-l10n-zh-plugin-1.19

The localization block on the home page points to the source location on the GitHub

Go to server reboot

has been Chinese


Configure Jenkins System Management--"management plug-in--" Sonarqube servers--"enter the corresponding parameter

Server Authentication token need to be available on Sonarqube server (in admin avatar-my account-security can be generated)

for scanning results, uploading to the server for Analysis .


Disable Sonarqube configuration--"scm--" Disable the SCM Sensor (default shutdown, click to open it)

(Disabling retrieval of error messages from source Control Manager appears to be simpler from source code, but this time follow the tutorial.)

Configuration does not have an active item error, connected to the local 127.0.0.1:9000 this address went up

Jenkinsurl Address/exit Reboot Jenkins

Still not.

After a data search, finally understand the original

You have to install a software, Sonarqube Scanner equals a client

Sonarqube is a server-side

Reference: http://blog.csdn.net/w171066/article/details/52366627


Configuration parameter Reference table: Https://docs.sonarqube.org/display/SONAR/Analysis+Parameters

Https://docs.sonarqube.org/display/PLUG/Java+Plugin+and+Bytecode


In a configured Jenkins project

Post steps action: Execute sonarqube Scanner--> Analysis Properties Fill out the following configuration

#项目key (with a value you think is meaningful)

Sonar.projectkey=2017-12-19-job

#项目名称
Sonar.projectname=cuimi-job
sonar.projectversion=1.0

#源码位置
Sonar.sources=cuimi-job/src/main/java

#编译后的class位置
Sonar.java.binaries=cuimi-job/target/classes

#java语言
Sonar.language=java
Sonar.sourceencoding=utf-8


In the presence of Sonarqube scanner exited with Non-zero code:1

The time should pay attention to see the error given by the hint information

2017-12-19 03:01:26 Alas. The dish is the original sin

=============================

Server reboot, restart process

Toggle User: Su-sonarqube

Start:/usr/local/sonarqube-6.7/bin/linux-x86-64/sonar.sh start


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.