1. Jenkins installation
Note: 1) jenkins downloads the war package and starts tomcat;
2) Jenkins initial plugins must all be installed successfully;
3) Automatic deployment plugin: Deploy to container Plugin
2. SonarQube installation
Note: 1) SonarQube is updated once every 12 weeks with the LTS version which is more stable;
2) SonarQube requires database version 5.6 or above
3) SonarQube Chinese package needs to select the version that SonarQube wants to match;
4) Sonar client SonarQube Scanner download address:
https://docs.sonarqube.org/display/SCAN/Analyzing+with+SonarQube+Scanner
Configuration file plus mysql address:
sonar.jdbc.url=jdbc:mysql://192.168.8.219:3306/sonarqube?useUnicode=true&characterEncoding=utf8&rewriteBatchedStatements=true&useConfigs=maxPerformance sonar.jdbc.username=root sonar.jdbc.password=root #----- Default SonarQube server sonar.host.url=http://localhost:9000 #----- Default source code encoding sonar.sourceEncoding=UTF-8
SonarQube Scanner needs to add environment variables:
SONAR_RUNNER_HOME=/usr/local/sonar-scanner-3 export PATH=$SONAR_RUNNER_HOME/bin:$PATH
3. Jenkins+SonarQube integration:
1) jenkins needs to download the plug-in SonarQube Scanner for Jenkins to configure jenkins to adjust the linux local sonar client configuration
jenkins->System Management-> Global Tool Configuration->SonarQube Scanner Configuration
2) Jenkins needs to configure an instance of SonarQube servers, that is, where is the sonar web side;
jenkins->system management->system settings-> SonarQube servers settings: The most important sonar token here is to configure the Server authentication token, this token needs to go to the sonar web side to generate;
Log in to the sonar web terminal with an administrator account
sonar-configuration->users under the permission tab->find the administrator user Administrator admin- >there is a token column behind->click inside to generate a token; after generation, fill in this token into the sonar-server configuration of jenkins;
3) Configure sonarqube, turn off the SCM sensor and configure it as yes. After this step is completed, jenkins can really use the sonarqube Server server, otherwise, an error will occur during quality analysis