1.1 Jenkins安装
参考安装教程:1.
1.2 Gitlab安装
参考安装教程:
1.3 SonarQube安装
参考安装教程:
二、集成管理配置
2.1 gitlab新建测试项目
参考安装教程:
2.2 Jenkins配置
2.2.1 安装Sonarqube Scanner插件
2.2.2 配置服务
2.2.2.1 系统配置中添加SonarQube Scanner
2.2.2.2 添加SonarQube Scanner凭证
2.2.2.3 在SonarQube生成令牌
2.2.2.3 添加SonarQube全局配置
2.2.3 安装JDK11.0
2.2.3.1 Jenkins安装所在系统安装JDK11
2.2.3.2 Jenkins全局配置JDK11
2.3 新建项目测试
2.3.1 通用设置
2.3.2 源码管理
2.3.3 构建触发器
2.3.4 Gitlab创建webhook
2.3.5 构建环境
重启脚本
2.3.6 构建(build)
2.3.7 Post Steps
2.3.8 项目启动
2.3.9 控制台日志
Started by GitLab push by Tom Smith
Running as SYSTEM
Building in workspace /var/lib/jenkins/workspace/Jenkins-SonarQube
The recommended git tool is: NONE
using credential Gilab-User
> /usr/bin/git rev-parse --is-inside-work-tree # timeout=10
Fetching changes from the remote Git repository
> /usr/bin/git config remote.origin.url http://192.168.61.72/zoops/sonar-test.git # timeout=10
Fetching upstream changes from http://192.168.61.72/zoops/sonar-test.git
> /usr/bin/git --version # timeout=10
> git --version # 'git version 1.8.3.1'
using GIT_ASKPASS to set credentials Gilab-User
> /usr/bin/git fetch --tags --progress http://192.168.61.72/zoops/sonar-test.git +refs/heads/*:refs/remotes/origin/* # timeout=10
skipping resolution of commit remotes/origin/master, since it originates from another repository
> /usr/bin/git rev-parse refs/remotes/origin/master^{commit} # timeout=10
Checking out Revision 6c690f78575233f95c5bf55a4aa023e674bdecbd (refs/remotes/origin/master)
> /usr/bin/git config core.sparsecheckout # timeout=10
> /usr/bin/git checkout -f 6c690f78575233f95c5bf55a4aa023e674bdecbd # timeout=10
Commit message: "--SonarQube-Scanner扫描"
> /usr/bin/git rev-list --no-walk d825e8d1cdeca95df59ffee021faef3004ef4466 # timeout=10
Parsing POMs
Established TCP socket on 35137
[Jenkins-SonarQube] $ /usr/local/java/bin/java -cp /var/lib/jenkins/plugins/maven-plugin/WEB-INF/lib/maven35-agent-1.13.jar:/usr/local/maven/boot/plexus-classworlds-2.6.0.jar:/usr/local/maven/conf/logging jenkins.maven3.agent.Maven35Main /usr/local/maven/ /var/cache/jenkins/war/WEB-INF/lib/remoting-4.6.jar /var/lib/jenkins/plugins/maven-plugin/WEB-INF/lib/maven35-interceptor-1.13.jar /var/lib/jenkins/plugins/maven-plugin/WEB-INF/lib/maven3-interceptor-commons-1.13.jar 35137
<===[JENKINS REMOTING CAPACITY]===>channel started
Executing Maven: -B -f /var/lib/jenkins/workspace/Jenkins-SonarQube/pom.xml -s /usr/local/maven/conf/settings.xml -gs /usr/local/maven/conf/settings.xml -DskipTests=true clean compile package
[INFO] Scanning for projects...
[INFO]
[INFO] -----------------------< com.jenkins:sonar-test >-----------------------
[INFO] Building sonar-test 0.0.1-SNAPSHOT
[INFO] --------------------------------[ jar ]---------------------------------
[INFO]
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ sonar-test ---
[INFO] Deleting /var/lib/jenkins/workspace/Jenkins-SonarQube/target
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ sonar-test ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 2 resources
[INFO]
[INFO] --- maven-compiler-plugin:3.8.1:compile (default-compile) @ sonar-test ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 1 source file to /var/lib/jenkins/workspace/Jenkins-SonarQube/target/classes
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ sonar-test ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 2 resources
[INFO]
[INFO] --- maven-compiler-plugin:3.8.1:compile (default-compile) @ sonar-test ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 1 source file to /var/lib/jenkins/workspace/Jenkins-SonarQube/target/classes
[INFO]
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ sonar-test ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory /var/lib/jenkins/workspace/Jenkins-SonarQube/src/test/resources
[INFO]
[INFO] --- maven-compiler-plugin:3.8.1:testCompile (default-testCompile) @ sonar-test ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 1 source file to /var/lib/jenkins/workspace/Jenkins-SonarQube/target/test-classes
[INFO]
[INFO] --- maven-surefire-plugin:2.12.4:test (default-test) @ sonar-test ---
[INFO] Tests are skipped.
[INFO]
[INFO] --- maven-jar-plugin:2.4:jar (default-jar) @ sonar-test ---
[INFO] Building jar: /var/lib/jenkins/workspace/Jenkins-SonarQube/target/sonar-test.jar
[INFO]
[INFO] --- spring-boot-maven-plugin:2.3.7.RELEASE:repackage (repackage) @ sonar-test ---
[INFO] Replacing main artifact with repackaged archive
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 3.878 s
[INFO] Finished at: 2021-02-20T22:31:53+08:00
[INFO] ------------------------------------------------------------------------
Waiting for Jenkins to finish collecting data
[JENKINS] Archiving /var/lib/jenkins/workspace/Jenkins-SonarQube/pom.xml to com.jenkins/sonar-test/0.0.1-SNAPSHOT/sonar-test-0.0.1-SNAPSHOT.pom
[JENKINS] Archiving /var/lib/jenkins/workspace/Jenkins-SonarQube/target/sonar-test.jar to com.jenkins/sonar-test/0.0.1-SNAPSHOT/sonar-test-0.0.1-SNAPSHOT.jar
channel stopped
[Jenkins-SonarQube] $ /var/lib/jenkins/tools/hudson.plugins.sonar.SonarRunnerInstallation/SonarQube-Scanner/bin/sonar-scanner -Dsonar.host.url=http://192.168.61.81:9000 ******** -Dproject.settings=/var/lib/jenkins/workspace/Jenkins-SonarQube/sonar-scanner.properties -Dsonar.java.binaries=/var/lib/jenkins/workspace/Jenkins-SonarQube/target/classes -Dsonar.sources=/var/lib/jenkins/workspace/Jenkins-SonarQube -Dsonar.projectBaseDir=/var/lib/jenkins/workspace/Jenkins-SonarQube
INFO: Scanner configuration file: /var/lib/jenkins/tools/hudson.plugins.sonar.SonarRunnerInstallation/SonarQube-Scanner/conf/sonar-scanner.properties
INFO: Project root configuration file: /var/lib/jenkins/workspace/Jenkins-SonarQube/sonar-scanner.properties
INFO: SonarQube Scanner 4.2.0.1873
INFO: Java 11.0.10 Oracle Corporation (64-bit)
INFO: Linux 3.10.0-1160.11.1.el7.x86_64 amd64
INFO: User cache: /root/.sonar/cache
INFO: SonarQube server 7.9.5
INFO: Default locale: "zh_CN", source code encoding: "UTF-8" (analysis is platform dependent)
INFO: Load global settings
INFO: Load global settings (done) | time=54ms
INFO: Server id: 48F3CEBB-AXe5bCYaWLFD_1L1uUGJ
INFO: User cache: /root/.sonar/cache
INFO: Load/download plugins
INFO: Load plugins index
INFO: Load plugins index (done) | time=34ms
INFO: Plugin [l10nzh] defines 'l10nen' as base plugin. This metadata can be removed from manifest of l10n plugins since version 5.2.
INFO: Load/download plugins (done) | time=74ms
INFO: Process project properties
INFO: Execute project builders
INFO: Execute project builders (done) | time=2ms
INFO: Project key: sonar-test
INFO: Base dir: /var/lib/jenkins/workspace/Jenkins-SonarQube
INFO: Working dir: /var/lib/jenkins/workspace/Jenkins-SonarQube/.scannerwork
INFO: Load project settings for component key: 'sonar-test'
INFO: Load project settings for component key: 'sonar-test' (done) | time=17ms
INFO: Load quality profiles
INFO: Load quality profiles (done) | time=35ms
INFO: Detected Jenkins
INFO: Load active rules
INFO: Load active rules (done) | time=394ms
INFO: Indexing files...
INFO: Project configuration:
INFO: 20 files indexed
INFO: Quality profile for java: Sonar way
INFO: Quality profile for web: Sonar way
INFO: Quality profile for xml: Sonar way
INFO: ------------- Run sensors on module sonar-test
INFO: Load metrics repository
INFO: Load metrics repository (done) | time