代码质量管理平台
一、checkout和打包功能
1.1 gitlab在新建一个文件


后续在写入内容

1.2 Jenkins新建一个任务

两个参数


1.3 流水线配置
copy仓库地址:

http://172.25.254.131/devops/jenkins.git

保存
1.4 生成流水线脚本
复制给i他地址。配置pipeline syntax




1.6 编写sonar.kenkinsfile文件
1#!/usr/bin/groovy 2 3node(){ 4//checkout 5checkout([$class: 'GitSCM', 6 branches: [[name: '*/master']], 7 doGenerateSubmoduleConfigurations: false, extensions: [], 8 submoduleCfg: [], 9 userRemoteConfigs: [[credentialsId: '87684a81-092f-4175-afff-6d9df42f2b14', 10 url: 'http://172.25.254.131/devops/jenkins.git']]]) 11//build 12def mvnHome = tool 'M2_HOME' 13sh "${mvnHome}/bin/mvn ${buildShell}" 14}
1.7 提交代码,构建
1Started by user admin 2Obtained sonar.jenkinsfile from git http://172.25.254.131/devops/jenkins.git 3Running in Durability level: MAX_SURVIVABILITY 4[Pipeline] Start of Pipeline 5[Pipeline] node 6Running on Jenkins in /root/.jenkins/workspace/test1-sonar-service_TEST 7[Pipeline] { 8[Pipeline] checkout 9using credential 87684a81-092f-4175-afff-6d9df42f2b14 10Cloning the remote Git repository 11Cloning repository http://172.25.254.131/devops/jenkins.git 12 > git init /root/.jenkins/workspace/test1-sonar-service_TEST # timeout=10 13Fetching upstream changes from http://172.25.254.131/devops/jenkins.git 14 > git --version # timeout=10 15using GIT_ASKPASS to set credentials 16 > git fetch --tags --progress http://172.25.254.131/devops/jenkins.git +refs/heads/*:refs/remotes/origin/* 17 > git config remote.origin.url http://172.25.254.131/devops/jenkins.git # timeout=10 18 > git config --add remote.origin.fetch +refs/heads/*:refs/remotes/origin/* # timeout=10 19 > git config remote.origin.url http://172.25.254.131/devops/jenkins.git # timeout=10 20Fetching upstream changes from http://172.25.254.131/devops/jenkins.git 21using GIT_ASKPASS to set credentials 22 > git fetch --tags --progress http://172.25.254.131/devops/jenkins.git +refs/heads/*:refs/remotes/origin/* 23 > git rev-parse refs/remotes/origin/master^{commit} # timeout=10 24 > git rev-parse refs/remotes/origin/origin/master^{commit} # timeout=10 25Checking out Revision e844e8870b03a721578cf029494ce02ce311c7fb (refs/remotes/origin/master) 26 > git config core.sparsecheckout # timeout=10 27 > git checkout -f e844e8870b03a721578cf029494ce02ce311c7fb 28Commit message: "Update sonar.jenkinsfile" 29First time build. Skipping changelog. 30[Pipeline] tool 31[Pipeline] } 32[Pipeline] // node 33[Pipeline] End of Pipeline 34groovy.lang.MissingPropertyException: No such property: buildShell for class: groovy.lang.Binding #没有这个参数 35 at groovy.lang.Binding.getVariable(Binding.java:63) 36 at org.jenkinsci.plugins.scriptsecurity.sandbox.groovy.SandboxInterceptor.onGetProperty(SandboxInterceptor.java:264) 37 at org.kohsuke.groovy.sandbox.impl.Checker$6.call(Checker.java:289) 38 at org.kohsuke.groovy.sandbox.impl.Checker.checkedGetProperty(Checker.java:293) 39 at org.kohsuke.groovy.sandbox.impl.Checker.checkedGetProperty(Checker.java:269) 40 at com.cloudbees.groovy.cps.sandbox.SandboxInvoker.getProperty(SandboxInvoker.java:29) 41 at com.cloudbees.groovy.cps.impl.PropertyAccessBlock.rawGet(PropertyAccessBlock.java:20) 42 at WorkflowScript.run(WorkflowScript:13) 43 at ___cps.transform___(Native Method) 44 at com.cloudbees.groovy.cps.impl.PropertyishBlock$ContinuationImpl.get(PropertyishBlock.java:74) 45 at com.cloudbees.groovy.cps.LValueBlock$GetAdapter.receive(LValueBlock.java:30) 46 at com.cloudbees.groovy.cps.impl.PropertyishBlock$ContinuationImpl.fixName(PropertyishBlock.java:66) 47 at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) 48 at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) 49 at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) 50 at java.lang.reflect.Method.invoke(Method.java:498) 51 at com.cloudbees.groovy.cps.impl.ContinuationPtr$ContinuationImpl.receive(ContinuationPtr.java:72) 52 at com.cloudbees.groovy.cps.impl.ConstantBlock.eval(ConstantBlock.java:21) 53 at com.cloudbees.groovy.cps.Next.step(Next.java:83) 54 at com.cloudbees.groovy.cps.Continuable$1.call(Continuable.java:174) 55 at com.cloudbees.groovy.cps.Continuable$1.call(Continuable.java:163) 56 at org.codehaus.groovy.runtime.GroovyCategorySupport$ThreadCategoryInfo.use(GroovyCategorySupport.java:129) 57 at org.codehaus.groovy.runtime.GroovyCategorySupport.use(GroovyCategorySupport.java:268) 58 at com.cloudbees.groovy.cps.Continuable.run0(Continuable.java:163) 59 at org.jenkinsci.plugins.workflow.cps.SandboxContinuable.access$101(SandboxContinuable.java:34) 60 at org.jenkinsci.plugins.workflow.cps.SandboxContinuable.lambda$run0$0(SandboxContinuable.java:59) 61 at org.jenkinsci.plugins.scriptsecurity.sandbox.groovy.GroovySandbox.runInSandbox(GroovySandbox.java:136) 62 at org.jenkinsci.plugins.workflow.cps.SandboxContinuable.run0(SandboxContinuable.java:58) 63 at org.jenkinsci.plugins.workflow.cps.CpsThread.runNextChunk(CpsThread.java:174) 64 at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup.run(CpsThreadGroup.java:347) 65 at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup.access$200(CpsThreadGroup.java:93) 66 at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup$2.call(CpsThreadGroup.java:259) 67 at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup$2.call(CpsThreadGroup.java:247) 68 at org.jenkinsci.plugins.workflow.cps.CpsVmExecutorService$2.call(CpsVmExecutorService.java:64) 69 at java.util.concurrent.FutureTask.run(FutureTask.java:266) 70 at hudson.remoting.SingleLaneExecutorService$1.run(SingleLaneExecutorService.java:131) 71 at jenkins.util.ContextResettingExecutorService$1.run(ContextResettingExecutorService.java:28) 72 at jenkins.security.ImpersonatingExecutorService$1.run(ImpersonatingExecutorService.java:59) 73 at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) 74 at java.util.concurrent.FutureTask.run(FutureTask.java:266) 75 at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) 76 at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) 77 at java.lang.Thread.run(Thread.java:748) 78Finished: FAILURE
1.8 添加一个参数,配置


失败,没有安装mvn

1.9 安装maven
[root@jenkins-master ~]# mkdir /usr/local/maven
[root@jenkins-master ~]# cd /usr/local/maven
[root@jenkins-master maven]# wget http://apache.communilink.net/maven/maven-3/3.6.1/binaries/apache-maven-3.6.1-bin.tar.gz
再次构建
1[ERROR] The goal you specified requires a project to execute but there is no POM in this directory (/root/.jenkins/workspace/test1-sonar-service_TEST). Please verify you invoked Maven from the correct directory. -> [Help 1] 2[ERROR] 3[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch. 4[ERROR] Re-run Maven using the -X switch to enable full debug logging. 5[ERROR] 6[ERROR] For more information about the errors and possible solutions, please read the following articles: 7[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MissingProjectException
1.10 选择另一个的gitlab的关于maven的project
http://172.25.254.131/tester/mvn-test01.git

重新配置流水线

流水线语法

生成流水线脚本
checkout([$class: 'GitSCM', branches: [[name: '*/master']], doGenerateSubmoduleConfigurations: false, extensions: [], submoduleCfg: [], userRemoteConfigs: [[url: 'http://172.25.254.131/tester/mvn-test01.git']]])
新建snoar.jenkinsfile

1#!/usr/bin/groovy 2node(){ 3//checkout 4checkout([$class: 'GitSCM', branches: [[name: '*/master']], 5 doGenerateSubmoduleConfigurations: false, 6 extensions: [], submoduleCfg: [], 7 userRemoteConfigs: [[url: 'http://172.25.254.131/tester/mvn-test01.git']]]) 8 9//build 10def mvnHome = tool 'M2_HOME' 11sh "${mvnHome}/bin/mvn ${buildShell}" 12}
1.11 再次构建
输出台信息
1Started by user admin 2Obtained sonar.jenkinsfile from git http://172.25.254.131/tester/mvn-test01.git 3Running in Durability level: MAX_SURVIVABILITY 4[Pipeline] Start of Pipeline 5[Pipeline] node 6Running on Jenkins in /root/.jenkins/workspace/test1-sonar-service_TEST 7[Pipeline] { 8[Pipeline] checkout 9No credentials specified 10 > git rev-parse --is-inside-work-tree # timeout=10 11Fetching changes from the remote Git repository 12 > git config remote.origin.url http://172.25.254.131/tester/mvn-test01.git # timeout=10 13Fetching upstream changes from http://172.25.254.131/tester/mvn-test01.git 14 > git --version # timeout=10 15 > git fetch --tags --progress http://172.25.254.131/tester/mvn-test01.git +refs/heads/*:refs/remotes/origin/* 16 > git rev-parse refs/remotes/origin/master^{commit} # timeout=10 17 > git rev-parse refs/remotes/origin/origin/master^{commit} # timeout=10 18Checking out Revision 7060102f73c77cbfbf9dc1d02ff0c905d17328a5 (refs/remotes/origin/master) 19 > git config core.sparsecheckout # timeout=10 20 > git checkout -f 7060102f73c77cbfbf9dc1d02ff0c905d17328a5 21Commit message: "Update jaja.jenkinsfile" 22 > git rev-list --no-walk 7060102f73c77cbfbf9dc1d02ff0c905d17328a5 # timeout=10 23[Pipeline] tool 24[Pipeline] sh 25+ /usr/local/maven/apache-maven-3.6.1/bin/mvn clean package -DskipTests 26[INFO] Scanning for projects... 27[INFO] 28[INFO] ---------------------< com.example.app:maven-app >---------------------- 29[INFO] Building maven-app 1.3-SNAPSHOT 30[INFO] --------------------------------[ jar ]--------------------------------- 31[INFO] 32[INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ maven-app --- 33[INFO] Deleting /root/.jenkins/workspace/test1-sonar-service_TEST/target 34[INFO] 35[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ maven-app --- 36[WARNING] Using platform encoding (UTF-8 actually) to copy filtered resources, i.e. build is platform dependent! 37[INFO] skip non existing resourceDirectory /root/.jenkins/workspace/test1-sonar-service_TEST/src/main/resources 38[INFO] 39[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ maven-app --- 40[INFO] Changes detected - recompiling the module! 41[WARNING] File encoding has not been set, using platform encoding UTF-8, i.e. build is platform dependent! 42[INFO] Compiling 1 source file to /root/.jenkins/workspace/test1-sonar-service_TEST/target/classes 43[INFO] 44[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ maven-app --- 45[WARNING] Using platform encoding (UTF-8 actually) to copy filtered resources, i.e. build is platform dependent! 46[INFO] skip non existing resourceDirectory /root/.jenkins/workspace/test1-sonar-service_TEST/src/test/resources 47[INFO] 48[INFO] --- maven-compiler-plugin:3.1:testCompile (default-testCompile) @ maven-app --- 49[INFO] Changes detected - recompiling the module! 50[WARNING] File encoding has not been set, using platform encoding UTF-8, i.e. build is platform dependent! 51[INFO] Compiling 1 source file to /root/.jenkins/workspace/test1-sonar-service_TEST/target/test-classes 52[INFO] 53[INFO] --- maven-surefire-plugin:2.12.4:test (default-test) @ maven-app --- 54[INFO] Tests are skipped. 55[INFO] 56[INFO] --- maven-jar-plugin:2.4:jar (default-jar) @ maven-app --- 57[INFO] Building jar: /root/.jenkins/workspace/test1-sonar-service_TEST/target/maven-app-1.3-SNAPSHOT.jar 58[INFO] ------------------------------------------------------------------------ 59[INFO] BUILD SUCCESS 60[INFO] ------------------------------------------------------------------------ 61[INFO] Total time: 2.386 s 62[INFO] Finished at: 2019-04-17T16:18:51+08:00 63[INFO] ------------------------------------------------------------------------ 64[Pipeline] } 65[Pipeline] // node 66[Pipeline] End of Pipeline 67Finished: SUCCESS
成功!!!
二 、结合sonar
2.1 安装sonar-scanner
[root@jenkins-master jenkins]# cd /usr/local/
[root@jenkins-master local]# mv sonar-scanner-3.3.0.1492-linux sonar-scanner
[root@jenkins-master ~]# vim /etc/profile
1export SONAR_SCANNER=/usr/local/sonar-scanner 2export PATH=$PATH:$JAVA_HOME/bin:$SONAR_SCANNER/bin
[root@jenkins-master ~]# source /etc/profile
这里使用sonnar命令完成


6f7a4c06ef06a8be9799097024c8f2f6fe2fafe7
2.2 修改sonar.kenjinsfile文件
1#!/usr/bin/groovy 2 3node(){ 4//checkout 5checkout([$class: 'GitSCM', branches: [[name: '*/master']], 6 doGenerateSubmoduleConfigurations: false, 7 extensions: [], submoduleCfg: [], 8 userRemoteConfigs: [[url: 'http://172.25.254.131/tester/mvn-test01.git']]]) 9 10//build 11def mvnHome = tool 'M2_HOME' 12sh "${mvnHome}/bin/mvn ${buildShell}" 13 14//Sonar 15sh """ 16 sonar-scanner \ 17 -Dsonar.projectKey=${serviceName} \ 18 -Dsonar.projectName=${serviceName} \ 19 -Dsonar.login=6f7a4c06ef06a8be9799097024c8f2f6fe2fafe7 \ 20 -Dsonar.source=src 21 -Dsonar.host.url=${sonarServer} \ 22 """ 23}
2.3 尝试构建修改
开始构建
结果信息
1[Pipeline] sh 2+ sonar-scanner -Dsonar.projectKey=test1-sonar-service -Dsonar.projectName=test1-sonar-service -Dsonar.login=6f7a4c06ef06a8be9799097024c8f2f6fe2fafe7 -Dsonar.host.url=src 3/root/.jenkins/workspace/test1-sonar-service_TEST@tmp/durable-f84d04fc/script.sh: line 2: sonar-scanner: command not found 4[Pipeline] } 5[Pipeline] // node 6[Pipeline] End of Pipeline 7ERROR: script returned exit code 127 8Finished: FAILURE
修改
1#!/usr/bin/groovy 2 3node(){ 4//checkout 5checkout([$class: 'GitSCM', branches: [[name: '*/master']], 6 doGenerateSubmoduleConfigurations: false, 7 extensions: [], submoduleCfg: [], 8 userRemoteConfigs: [[url: 'http://172.25.254.131/tester/mvn-test01.git']]]) 9 10//build 11def mvnHome = tool 'M2_HOME' 12sh "${mvnHome}/bin/mvn ${buildShell}" 13 14//Sonar 15sh """ 16 /usr/local/sonar-scanner/bin/sonar-scanner \ 17 -Dsonar.projectKey=${serviceName} \ 18 -Dsonar.projectName=${serviceName} \ 19 -Dsonar.login=6f7a4c06ef06a8be9799097024c8f2f6fe2fafe7 \ 20 -Dsonar.source=src 21 -Dsonar.host.url=${sonarServer} \ -Dsonar.java.binaries=/root/.jenkins/workspace/test1-sonar-service_TEST/target/classes \ 22 """ 23}
构建
1INFO: ------------------------------------------------------------------------ 2ERROR: Error during SonarQube Scanner execution 3ERROR: You must define the following mandatory properties for 'test1-sonar-service': sonar.sources 4ERROR: 5ERROR: Re-run SonarQube Scanner using the -X switch to enable full debug logging. 6[Pipeline] } 7[Pipeline] // node 8[Pipeline] End of Pipeline 9ERROR: script returned exit code 1 10Finished: FAILURE
修改:
1#!/usr/bin/groovy 2 3node(){ 4//checkout 5checkout([$class: 'GitSCM', branches: [[name: '*/master']], 6 doGenerateSubmoduleConfigurations: false, 7 extensions: [], submoduleCfg: [], 8 userRemoteConfigs: [[url: 'http://172.25.254.131/tester/mvn-test01.git']]]) 9 10//build 11def mvnHome = tool 'M2_HOME' 12sh "${mvnHome}/bin/mvn ${buildShell}" 13 14//Sonar 15sh """ 16 /usr/local/sonar-scanner/bin/sonar-scanner \ 17 -Dsonar.projectKey=${serviceName} \ 18 -Dsonar.projectName=${serviceName} \ 19 -Dsonar.login=6f7a4c06ef06a8be9799097024c8f2f6fe2fafe7 \ 20 -Dsonar.sources=src \ 21 -Dsonar.host.url=${sonarServer} \ 22 23 """ 24}
再次构建
1Started by user admin 2Obtained sonar.jenkinsfile from git http://172.25.254.131/tester/mvn-test01.git 3Running in Durability level: MAX_SURVIVABILITY 4[Pipeline] Start of Pipeline 5[Pipeline] node 6Running on Jenkins in /root/.jenkins/workspace/test1-sonar-service_TEST 7[Pipeline] { 8[Pipeline] checkout 9No credentials specified 10 > git rev-parse --is-inside-work-tree # timeout=10 11Fetching changes from the remote Git repository 12 > git config remote.origin.url http://172.25.254.131/tester/mvn-test01.git # timeout=10 13Fetching upstream changes from http://172.25.254.131/tester/mvn-test01.git 14 > git --version # timeout=10 15 > git fetch --tags --progress http://172.25.254.131/tester/mvn-test01.git +refs/heads/*:refs/remotes/origin/* 16 > git rev-parse refs/remotes/origin/master^{commit} # timeout=10 17 > git rev-parse refs/remotes/origin/origin/master^{commit} # timeout=10 18Checking out Revision ad3e34fe85103fdf2229159cf14e8f17493b799a (refs/remotes/origin/master) 19 > git config core.sparsecheckout # timeout=10 20 > git checkout -f ad3e34fe85103fdf2229159cf14e8f17493b799a 21Commit message: "Update sonar.jenkinsfile" 22 > git rev-list --no-walk d57ef66ee0b2a069a63da5fe6afc2b1c7d276e67 # timeout=10 23[Pipeline] tool 24[Pipeline] sh 25+ /usr/local/maven/apache-maven-3.6.1/bin/mvn clean package -DskipTests 26[INFO] Scanning for projects... 27[INFO] 28[INFO] ---------------------< com.example.app:maven-app >---------------------- 29[INFO] Building maven-app 1.3-SNAPSHOT 30[INFO] --------------------------------[ jar ]--------------------------------- 31[INFO] 32[INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ maven-app --- 33[INFO] Deleting /root/.jenkins/workspace/test1-sonar-service_TEST/target 34[INFO] 35[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ maven-app --- 36[WARNING] Using platform encoding (UTF-8 actually) to copy filtered resources, i.e. build is platform dependent! 37[INFO] skip non existing resourceDirectory /root/.jenkins/workspace/test1-sonar-service_TEST/src/main/resources 38[INFO] 39[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ maven-app --- 40[INFO] Changes detected - recompiling the module! 41[WARNING] File encoding has not been set, using platform encoding UTF-8, i.e. build is platform dependent! 42[INFO] Compiling 1 source file to /root/.jenkins/workspace/test1-sonar-service_TEST/target/classes 43[INFO] 44[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ maven-app --- 45[WARNING] Using platform encoding (UTF-8 actually) to copy filtered resources, i.e. build is platform dependent! 46[INFO] skip non existing resourceDirectory /root/.jenkins/workspace/test1-sonar-service_TEST/src/test/resources 47[INFO] 48[INFO] --- maven-compiler-plugin:3.1:testCompile (default-testCompile) @ maven-app --- 49[INFO] Changes detected - recompiling the module! 50[WARNING] File encoding has not been set, using platform encoding UTF-8, i.e. build is platform dependent! 51[INFO] Compiling 1 source file to /root/.jenkins/workspace/test1-sonar-service_TEST/target/test-classes 52[INFO] 53[INFO] --- maven-surefire-plugin:2.12.4:test (default-test) @ maven-app --- 54[INFO] Tests are skipped. 55[INFO] 56[INFO] --- maven-jar-plugin:2.4:jar (default-jar) @ maven-app --- 57[INFO] Building jar: /root/.jenkins/workspace/test1-sonar-service_TEST/target/maven-app-1.3-SNAPSHOT.jar 58[INFO] ------------------------------------------------------------------------ 59[INFO] BUILD SUCCESS 60[INFO] ------------------------------------------------------------------------ 61[INFO] Total time: 4.356 s 62[INFO] Finished at: 2019-04-20T02:09:51+08:00 63[INFO] ------------------------------------------------------------------------ 64[Pipeline] sh 65+ /usr/local/sonar-scanner/bin/sonar-scanner -Dsonar.projectKey=test1-sonar-service -Dsonar.projectName=test1-sonar-service -Dsonar.login=6f7a4c06ef06a8be9799097024c8f2f6fe2fafe7 -Dsonar.sources=src -Dsonar.host.url=http://172.25.254.133:9000 66INFO: Scanner configuration file: /usr/local/sonar-scanner/conf/sonar-scanner.properties 67INFO: Project root configuration file: NONE 68INFO: SonarQube Scanner 3.3.0.1492 69INFO: Java 1.8.0_121 Oracle Corporation (64-bit) 70INFO: Linux 3.10.0-693.el7.x86_64 amd64 71INFO: User cache: /root/.sonar/cache 72INFO: SonarQube server 6.7.7 73INFO: Default locale: "en_US", source code encoding: "UTF-8" 74INFO: Publish mode 75INFO: Load global settings 76INFO: Load global settings (done) | time=57ms 77INFO: Server id: A623D34D-AWoVn6_8P1KovjAYWYot 78INFO: User cache: /root/.sonar/cache 79INFO: Load plugins index 80INFO: Load plugins index (done) | time=136ms 81INFO: Plugin [l10nzh] defines 'l10nen' as base plugin. This metadata can be removed from manifest of l10n plugins since version 5.2. 82INFO: Process project properties 83INFO: Load project repositories 84INFO: Load project repositories (done) | time=13ms 85INFO: Load quality profiles 86INFO: Load quality profiles (done) | time=36ms 87INFO: Load active rules 88INFO: Load active rules (done) | time=290ms 89INFO: Load metrics repository 90INFO: Load metrics repository (done) | time=39ms 91INFO: Project key: test1-sonar-service 92INFO: ------------- Scan test1-sonar-service 93INFO: Load server rules 94INFO: Load server rules (done) | time=23ms 95INFO: Base dir: /root/.jenkins/workspace/test1-sonar-service_TEST 96INFO: Working dir: /root/.jenkins/workspace/test1-sonar-service_TEST/.scannerwork 97INFO: Source paths: src 98INFO: Source encoding: UTF-8, default locale: en_US 99INFO: Index files 100INFO: 2 files indexed 101INFO: Sensor Zero Coverage Sensor 102INFO: Sensor Zero Coverage Sensor (done) | time=9ms 103INFO: Sensor CPD Block Indexer 104INFO: Sensor CPD Block Indexer (done) | time=0ms 105INFO: SCM Publisher is disabled 106INFO: Calculating CPD for 0 files 107INFO: CPD calculation finished 108INFO: Analysis report generated in 49ms, dir size=1 KB 109INFO: Analysis reports compressed in 6ms, zip size=1 KB 110INFO: Analysis report uploaded in 442ms 111INFO: ANALYSIS SUCCESSFUL, you can browse http://172.25.254.133:9000/dashboard/index/test1-sonar-service 112INFO: Note that you will be able to access the updated dashboard once the server has processed the submitted analysis report 113INFO: More about the report processing at http://172.25.254.133:9000/api/ce/task?id=AWpPClxumO3e1qpxfNZm 114INFO: Task total time: 1.776 s 115INFO: ------------------------------------------------------------------------ 116INFO: EXECUTION SUCCESS 117INFO: ------------------------------------------------------------------------ 118INFO: Total time: 3.104s 119INFO: Final Memory: 8M/129M 120INFO: ------------------------------------------------------------------------ 121[Pipeline] } 122[Pipeline] // node 123[Pipeline] End of Pipeline 124Finished: SUCCESS
完成
三、使用slave
3.1 在任务配置加一个选项参数

sonar.jenkinsfile文件
1#!/usr/bin/groovy 2 3node("${nodeSlave}"){ 4//checkout 5checkout([$class: 'GitSCM', branches: [[name: '*/master']], 6 doGenerateSubmoduleConfigurations: false, 7 extensions: [], submoduleCfg: [], 8 userRemoteConfigs: [[url: 'http://172.25.254.131/tester/mvn-test01.git']]]) 9 10//build 11def mvnHome = tool 'M2_HOME' 12sh "${mvnHome}/bin/mvn ${buildShell}"}
[root@jenkins-master ~]# scp -r /usr/local/sonar-scanner 172.25.254.134:/usr/local/
[root@node5 ~]# vim /etc/profile
1export SONAR_SCANNER=/usr/local/sonar-scanner 2export PATH=$PATH:$SONAR_SCANNER/bin
[root@node5 ~]# source /etc/profile
执行构建的时候,会一直报错
1[Pipeline] tool 2[Pipeline] sh 3+ /usr/local/maven/apache-maven-3.6.1/bin/mvn clean package -DskipTests 4The JAVA_HOME environment variable is not defined correctly 5This environment variable is needed to run this program 6NB: JAVA_HOME should point to a JDK not a JRE 7[Pipeline] } 8[Pipeline] // node 9[Pipeline] End of Pipeline 10ERROR: script returned exit code 1 11Finished: FAILURE
然后在salve1节点一直排查,jdk的环境变量没有问题,mvn -v执行正常,
[root@node5 test1-sonar-service_TEST]# /usr/local/maven/apache-maven-3.6.1/bin/mvn clean package -DskipTests也执行成功
1[INFO] Scanning for projects... 2[INFO] 3[INFO] ---------------------< com.example.app:maven-app >---------------------- 4[INFO] Building maven-app 1.3-SNAPSHOT 5[INFO] --------------------------------[ jar ]--------------------------------- 6[INFO] 7[INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ maven-app --- 8[INFO] Deleting /var/jenkins/workspace/test1-sonar-service_TEST/target 9[INFO] 10[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ maven-app --- 11[WARNING] Using platform encoding (UTF-8 actually) to copy filtered resources, i.e. build is platform dependent! 12[INFO] skip non existing resourceDirectory /var/jenkins/workspace/test1-sonar-service_TEST/src/main/resources 13[INFO] 14[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ maven-app --- 15[INFO] Changes detected - recompiling the module! 16[WARNING] File encoding has not been set, using platform encoding UTF-8, i.e. build is platform dependent! 17[INFO] Compiling 1 source file to /var/jenkins/workspace/test1-sonar-service_TEST/target/classes 18[INFO] 19[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ maven-app --- 20[WARNING] Using platform encoding (UTF-8 actually) to copy filtered resources, i.e. build is platform dependent! 21[INFO] skip non existing resourceDirectory /var/jenkins/workspace/test1-sonar-service_TEST/src/test/resources 22[INFO] 23[INFO] --- maven-compiler-plugin:3.1:testCompile (default-testCompile) @ maven-app --- 24[INFO] Changes detected - recompiling the module! 25[WARNING] File encoding has not been set, using platform encoding UTF-8, i.e. build is platform dependent! 26[INFO] Compiling 1 source file to /var/jenkins/workspace/test1-sonar-service_TEST/target/test-classes 27[INFO] 28[INFO] --- maven-surefire-plugin:2.12.4:test (default-test) @ maven-app --- 29[INFO] Tests are skipped. 30[INFO] 31[INFO] --- maven-jar-plugin:2.4:jar (default-jar) @ maven-app --- 32[INFO] Building jar: /var/jenkins/workspace/test1-sonar-service_TEST/target/maven-app-1.3-SNAPSHOT.jar 33[INFO] ------------------------------------------------------------------------ 34[INFO] BUILD SUCCESS 35[INFO] ------------------------------------------------------------------------ 36[INFO] Total time: 2.030 s 37[INFO] Finished at: 2019-04-24T23:59:46+08:00
但是构建一直失败,卡了三四个小时,后来重启了master和slave节点,再一次构建执行成功,是个大坑
成功输出结果
1Started by user admin 2Obtained sonar.jenkinsfile from git http://172.25.254.131/tester/mvn-test01.git 3Running in Durability level: MAX_SURVIVABILITY 4[Pipeline] Start of Pipeline 5[Pipeline] node 6Running on slave1 in /var/jenkins/workspace/test1-sonar-service_TEST@2 7[Pipeline] { 8[Pipeline] checkout 9No credentials specified 10Fetching changes from the remote Git repository 11 > git rev-parse --is-inside-work-tree # timeout=10 12 > git config remote.origin.url http://172.25.254.131/tester/mvn-test01.git # timeout=10 13Fetching upstream changes from http://172.25.254.131/tester/mvn-test01.git 14 > git --version # timeout=10 15 > git fetch --tags --progress http://172.25.254.131/tester/mvn-test01.git +refs/heads/*:refs/remotes/origin/* 16Checking out Revision 401249b8852695b6c9e1ed1cfea359101daffab4 (refs/remotes/origin/master) 17 > git rev-parse refs/remotes/origin/master^{commit} # timeout=10 18 > git rev-parse refs/remotes/origin/origin/master^{commit} # timeout=10 19 > git config core.sparsecheckout # timeout=10 20 > git checkout -f 401249b8852695b6c9e1ed1cfea359101daffab4 21Commit message: "Update sonar.jenkinsfile" 22[Pipeline] tool 23[Pipeline] sh 24 > git rev-list --no-walk 401249b8852695b6c9e1ed1cfea359101daffab4 # timeout=10 25+ /usr/local/maven/apache-maven-3.6.1/bin/mvn clean package -DskipTests 26[INFO] Scanning for projects... 27[INFO] 28[INFO] ---------------------< com.example.app:maven-app >---------------------- 29[INFO] Building maven-app 1.3-SNAPSHOT 30[INFO] --------------------------------[ jar ]--------------------------------- 31[INFO] 32[INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ maven-app --- 33[INFO] Deleting /var/jenkins/workspace/test1-sonar-service_TEST@2/target 34[INFO] 35[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ maven-app --- 36[WARNING] Using platform encoding (UTF-8 actually) to copy filtered resources, i.e. build is platform dependent! 37[INFO] skip non existing resourceDirectory /var/jenkins/workspace/test1-sonar-service_TEST@2/src/main/resources 38[INFO] 39[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ maven-app --- 40[INFO] Changes detected - recompiling the module! 41[WARNING] File encoding has not been set, using platform encoding UTF-8, i.e. build is platform dependent! 42[INFO] Compiling 1 source file to /var/jenkins/workspace/test1-sonar-service_TEST@2/target/classes 43[INFO] 44[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ maven-app --- 45[WARNING] Using platform encoding (UTF-8 actually) to copy filtered resources, i.e. build is platform dependent! 46[INFO] skip non existing resourceDirectory /var/jenkins/workspace/test1-sonar-service_TEST@2/src/test/resources 47[INFO] 48[INFO] --- maven-compiler-plugin:3.1:testCompile (default-testCompile) @ maven-app --- 49[INFO] Changes detected - recompiling the module! 50[WARNING] File encoding has not been set, using platform encoding UTF-8, i.e. build is platform dependent! 51[INFO] Compiling 1 source file to /var/jenkins/workspace/test1-sonar-service_TEST@2/target/test-classes 52[INFO] 53[INFO] --- maven-surefire-plugin:2.12.4:test (default-test) @ maven-app --- 54[INFO] Tests are skipped. 55[INFO] 56[INFO] --- maven-jar-plugin:2.4:jar (default-jar) @ maven-app --- 57[INFO] Building jar: /var/jenkins/workspace/test1-sonar-service_TEST@2/target/maven-app-1.3-SNAPSHOT.jar 58[INFO] ------------------------------------------------------------------------ 59[INFO] BUILD SUCCESS 60[INFO] ------------------------------------------------------------------------ 61[INFO] Total time: 6.972 s 62[INFO] Finished at: 2019-04-24T23:58:36+08:00 63[INFO] ------------------------------------------------------------------------ 64[Pipeline] } 65[Pipeline] // node 66[Pipeline] End of Pipeline 67Finished: SUCCESS
3.2 结合sonar
修改sonar.jenkinsfile
1#!/usr/bin/groovy 2 3node("${nodeSlave}"){ 4//checkout 5checkout([$class: 'GitSCM', branches: [[name: '*/master']], 6 doGenerateSubmoduleConfigurations: false, 7 extensions: [], submoduleCfg: [], 8 userRemoteConfigs: [[url: 'http://172.25.254.131/tester/mvn-test01.git']]]) 9 10//build 11def mvnHome = tool 'M2_HOME' 12sh "${mvnHome}/bin/mvn ${buildShell}" 13 14//Sonar 15sh """ 16 /usr/local/sonar-scanner/bin/sonar-scanner \ 17 -Dsonar.projectKey=${serviceName} \ 18 -Dsonar.projectName=${serviceName} \ 19 -Dsonar.login=6f7a4c06ef06a8be9799097024c8f2f6fe2fafe7 \ 20 -Dsonar.sources=src \ 21 -Dsonar.host.url=${sonarServer} \ 22 23 """ 24}
构建也顺利完成

1Started by user admin 2Obtained sonar.jenkinsfile from git http://172.25.254.131/tester/mvn-test01.git 3Running in Durability level: MAX_SURVIVABILITY 4[Pipeline] Start of Pipeline 5[Pipeline] node 6Running on slave1 in /var/jenkins/workspace/test1-sonar-service_TEST 7[Pipeline] { 8[Pipeline] checkout 9No credentials specified 10Fetching changes from the remote Git repository 11Checking out Revision da77bf327b6d4c057ba469fdd5189f78ab6d850c (refs/remotes/origin/master) 12 > git rev-parse --is-inside-work-tree # timeout=10 13 > git config remote.origin.url http://172.25.254.131/tester/mvn-test01.git # timeout=10 14Fetching upstream changes from http://172.25.254.131/tester/mvn-test01.git 15 > git --version # timeout=10 16 > git fetch --tags --progress http://172.25.254.131/tester/mvn-test01.git +refs/heads/*:refs/remotes/origin/* 17 > git rev-parse refs/remotes/origin/master^{commit} # timeout=10 18 > git rev-parse refs/remotes/origin/origin/master^{commit} # timeout=10 19Commit message: "Update sonar.jenkinsfile" 20[Pipeline] tool 21[Pipeline] sh 22+ /usr/local/maven/apache-maven-3.6.1/bin/mvn clean package -DskipTests 23 > git config core.sparsecheckout # timeout=10 24 > git checkout -f da77bf327b6d4c057ba469fdd5189f78ab6d850c 25 > git rev-list --no-walk 401249b8852695b6c9e1ed1cfea359101daffab4 # timeout=10 26[INFO] Scanning for projects... 27[INFO] 28[INFO] ---------------------< com.example.app:maven-app >---------------------- 29[INFO] Building maven-app 1.3-SNAPSHOT 30[INFO] --------------------------------[ jar ]--------------------------------- 31[INFO] 32[INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ maven-app --- 33[INFO] Deleting /var/jenkins/workspace/test1-sonar-service_TEST/target 34[INFO] 35[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ maven-app --- 36[WARNING] Using platform encoding (UTF-8 actually) to copy filtered resources, i.e. build is platform dependent! 37[INFO] skip non existing resourceDirectory /var/jenkins/workspace/test1-sonar-service_TEST/src/main/resources 38[INFO] 39[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ maven-app --- 40[INFO] Changes detected - recompiling the module! 41[WARNING] File encoding has not been set, using platform encoding UTF-8, i.e. build is platform dependent! 42[INFO] Compiling 1 source file to /var/jenkins/workspace/test1-sonar-service_TEST/target/classes 43[INFO] 44[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ maven-app --- 45[WARNING] Using platform encoding (UTF-8 actually) to copy filtered resources, i.e. build is platform dependent! 46[INFO] skip non existing resourceDirectory /var/jenkins/workspace/test1-sonar-service_TEST/src/test/resources 47[INFO] 48[INFO] --- maven-compiler-plugin:3.1:testCompile (default-testCompile) @ maven-app --- 49[INFO] Changes detected - recompiling the module! 50[WARNING] File encoding has not been set, using platform encoding UTF-8, i.e. build is platform dependent! 51[INFO] Compiling 1 source file to /var/jenkins/workspace/test1-sonar-service_TEST/target/test-classes 52[INFO] 53[INFO] --- maven-surefire-plugin:2.12.4:test (default-test) @ maven-app --- 54[INFO] Tests are skipped. 55[INFO] 56[INFO] --- maven-jar-plugin:2.4:jar (default-jar) @ maven-app --- 57[INFO] Building jar: /var/jenkins/workspace/test1-sonar-service_TEST/target/maven-app-1.3-SNAPSHOT.jar 58[INFO] ------------------------------------------------------------------------ 59[INFO] BUILD SUCCESS 60[INFO] ------------------------------------------------------------------------ 61[INFO] Total time: 2.938 s 62[INFO] Finished at: 2019-04-25T00:04:51+08:00 63[INFO] ------------------------------------------------------------------------ 64[Pipeline] sh 65+ /usr/local/sonar-scanner/bin/sonar-scanner -Dsonar.projectKey=test1-sonar-service -Dsonar.projectName=test1-sonar-service -Dsonar.login=6f7a4c06ef06a8be9799097024c8f2f6fe2fafe7 -Dsonar.sources=src -Dsonar.host.url=http://172.25.254.133:9000 66INFO: Scanner configuration file: /usr/local/sonar-scanner/conf/sonar-scanner.properties 67INFO: Project root configuration file: NONE 68INFO: SonarQube Scanner 3.3.0.1492 69INFO: Java 1.8.0_121 Oracle Corporation (64-bit) 70INFO: Linux 3.10.0-693.el7.x86_64 amd64 71INFO: User cache: /root/.sonar/cache 72INFO: SonarQube server 6.7.7 73INFO: Default locale: "en_US", source code encoding: "UTF-8" 74INFO: Publish mode 75INFO: Load global settings 76INFO: Load global settings (done) | time=172ms 77INFO: Server id: A623D34D-AWoVn6_8P1KovjAYWYot 78INFO: User cache: /root/.sonar/cache 79INFO: Load plugins index 80INFO: Load plugins index (done) | time=340ms 81INFO: Download sonar-l10n-zh-plugin-1.19.jar 82INFO: Plugin [l10nzh] defines 'l10nen' as base plugin. This metadata can be removed from manifest of l10n plugins since version 5.2. 83INFO: Download sonar-python-plugin-1.13.0.2922.jar 84INFO: Process project properties 85INFO: Load project repositories 86INFO: Load project repositories (done) | time=59ms 87INFO: Load quality profiles 88INFO: Load quality profiles (done) | time=21ms 89INFO: Load active rules 90INFO: Load active rules (done) | time=81ms 91INFO: Load metrics repository 92INFO: Load metrics repository (done) | time=27ms 93INFO: Project key: test1-sonar-service 94INFO: ------------- Scan test1-sonar-service 95INFO: Load server rules 96INFO: Load server rules (done) | time=62ms 97INFO: Base dir: /var/jenkins/workspace/test1-sonar-service_TEST 98INFO: Working dir: /var/jenkins/workspace/test1-sonar-service_TEST/.scannerwork 99INFO: Source paths: src 100INFO: Source encoding: UTF-8, default locale: en_US 101INFO: Index files 102INFO: 2 files indexed 103INFO: Sensor Zero Coverage Sensor 104INFO: Sensor Zero Coverage Sensor (done) | time=11ms 105INFO: Sensor CPD Block Indexer 106INFO: Sensor CPD Block Indexer (done) | time=0ms 107INFO: SCM Publisher is disabled 108INFO: Calculating CPD for 0 files 109INFO: CPD calculation finished 110INFO: Analysis report generated in 46ms, dir size=1 KB 111INFO: Analysis reports compressed in 4ms, zip size=1 KB 112INFO: Analysis report uploaded in 40ms 113INFO: ANALYSIS SUCCESSFUL, you can browse http://172.25.254.133:9000/dashboard/index/test1-sonar-service 114INFO: Note that you will be able to access the updated dashboard once the server has processed the submitted analysis report 115INFO: More about the report processing at http://172.25.254.133:9000/api/ce/task?id=AWpQF7VgmO3e1qpxfNZn 116INFO: Task total time: 1.585 s 117INFO: ------------------------------------------------------------------------ 118INFO: EXECUTION SUCCESS 119INFO: ------------------------------------------------------------------------ 120INFO: Total time: 3.742s 121INFO: Final Memory: 12M/90M 122INFO: ------------------------------------------------------------------------ 123[Pipeline] } 124[Pipeline] // node 125[Pipeline] End of Pipeline 126Finished: SUCCESS
View Code
四、现有优化
4.1 修改sonar.jenkinsfile
1#!/usr/bin/groovy 2 3String skipSonar = "${env.skipSonar}" 4String skipTset = "${env.skipTest}" 5 6node("${nodeSlave}"){ 7//checkout 8stage 'checkout' 9 checkout([$class: 'GitSCM', branches: [[name: '*/master']], 10 doGenerateSubmoduleConfigurations: false, 11 extensions: [], submoduleCfg: [], 12 userRemoteConfigs: [[url: 'http://172.25.254.131/tester/mvn-test01.git']]]) 13//build 14stage 'Build' 15 if ("${skipTest}" == 'true'){ 16 mvnHome = tool 'M2_HOME' 17 sh "${mvnHome}/bin/mvn ${buildShell} -DskipTests" 18 } 19 else{ 20 sh "${mvnHome}/bin/mvn ${buildShell}" 21 } 22 23//Sonar 24stage 'Sonar' 25 sh """ 26 /usr/local/sonar-scanner/bin/sonar-scanner \ 27 -Dsonar.projectKey=${serviceName} \ 28 -Dsonar.projectName=${serviceName} \ 29 -Dsonar.login=6f7a4c06ef06a8be9799097024c8f2f6fe2fafe7 \ 30 -Dsonar.sources=src \ 31 -Dsonar.host.url=${sonarServer} \ 32 33 """ 34}
4.2 jenkins加几个开关
任务配置



4.3 开始构建

4.4 执行结果
1Started by user admin 2Obtained sonar.jenkinsfile from git http://172.25.254.131/tester/mvn-test01.git 3Running in Durability level: MAX_SURVIVABILITY 4[Pipeline] Start of Pipeline 5[Pipeline] node 6Running on slave1 in /var/jenkins/workspace/test1-sonar-service_TEST 7[Pipeline] { 8[Pipeline] stage (checkout) 9Using the ‘stage’ step without a block argument is deprecated 10Entering stage checkout 11Proceeding 12[Pipeline] checkout 13No credentials specified 14Fetching changes from the remote Git repository 15Checking out Revision ae3a97f638dd6827893927b958f0996c810a5b5c (refs/remotes/origin/master) 16Commit message: "Update sonar.jenkinsfile" 17[Pipeline] stage (Build) 18Using the ‘stage’ step without a block argument is deprecated 19Entering stage Build 20Proceeding 21[Pipeline] tool 22[Pipeline] sh 23+ /usr/local/maven/apache-maven-3.6.1/bin/mvn clean package -DskipTests 24 > git rev-parse --is-inside-work-tree # timeout=10 25 > git config remote.origin.url http://172.25.254.131/tester/mvn-test01.git # timeout=10 26Fetching upstream changes from http://172.25.254.131/tester/mvn-test01.git 27 > git --version # timeout=10 28 > git fetch --tags --progress http://172.25.254.131/tester/mvn-test01.git +refs/heads/*:refs/remotes/origin/* 29 > git rev-parse refs/remotes/origin/master^{commit} # timeout=10 30 > git rev-parse refs/remotes/origin/origin/master^{commit} # timeout=10 31 > git config core.sparsecheckout # timeout=10 32 > git checkout -f ae3a97f638dd6827893927b958f0996c810a5b5c 33 > git rev-list --no-walk 08386a6b4836d2e277eca119c1651df0158ed964 # timeout=10 34[INFO] Scanning for projects... 35[INFO] 36[INFO] ---------------------< com.example.app:maven-app >---------------------- 37[INFO] Building maven-app 1.3-SNAPSHOT 38[INFO] --------------------------------[ jar ]--------------------------------- 39[INFO] 40[INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ maven-app --- 41[INFO] Deleting /var/jenkins/workspace/test1-sonar-service_TEST/target 42[INFO] 43[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ maven-app --- 44[WARNING] Using platform encoding (UTF-8 actually) to copy filtered resources, i.e. build is platform dependent! 45[INFO] skip non existing resourceDirectory /var/jenkins/workspace/test1-sonar-service_TEST/src/main/resources 46[INFO] 47[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ maven-app --- 48[INFO] Changes detected - recompiling the module! 49[WARNING] File encoding has not been set, using platform encoding UTF-8, i.e. build is platform dependent! 50[INFO] Compiling 1 source file to /var/jenkins/workspace/test1-sonar-service_TEST/target/classes 51[INFO] 52[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ maven-app --- 53[WARNING] Using platform encoding (UTF-8 actually) to copy filtered resources, i.e. build is platform dependent! 54[INFO] skip non existing resourceDirectory /var/jenkins/workspace/test1-sonar-service_TEST/src/test/resources 55[INFO] 56[INFO] --- maven-compiler-plugin:3.1:testCompile (default-testCompile) @ maven-app --- 57[INFO] Changes detected - recompiling the module! 58[WARNING] File encoding has not been set, using platform encoding UTF-8, i.e. build is platform dependent! 59[INFO] Compiling 1 source file to /var/jenkins/workspace/test1-sonar-service_TEST/target/test-classes 60[INFO] 61[INFO] --- maven-surefire-plugin:2.12.4:test (default-test) @ maven-app --- 62[INFO] Tests are skipped. 63[INFO] 64[INFO] --- maven-jar-plugin:2.4:jar (default-jar) @ maven-app --- 65[INFO] Building jar: /var/jenkins/workspace/test1-sonar-service_TEST/target/maven-app-1.3-SNAPSHOT.jar 66[INFO] ------------------------------------------------------------------------ 67[INFO] BUILD SUCCESS 68[INFO] ------------------------------------------------------------------------ 69[INFO] Total time: 2.321 s 70[INFO] Finished at: 2019-04-25T09:16:36+08:00 71[INFO] ------------------------------------------------------------------------ 72[Pipeline] stage (Sonar) 73Using the ‘stage’ step without a block argument is deprecated 74Entering stage Sonar 75Proceeding 76[Pipeline] sh 77+ /usr/local/sonar-scanner/bin/sonar-scanner -Dsonar.projectKey=test1-sonar-service -Dsonar.projectName=test1-sonar-service -Dsonar.login=6f7a4c06ef06a8be9799097024c8f2f6fe2fafe7 -Dsonar.sources=src -Dsonar.host.url=http://172.25.254.133:9000 78INFO: Scanner configuration file: /usr/local/sonar-scanner/conf/sonar-scanner.properties 79INFO: Project root configuration file: NONE 80INFO: SonarQube Scanner 3.3.0.1492 81INFO: Java 1.8.0_121 Oracle Corporation (64-bit) 82INFO: Linux 3.10.0-693.el7.x86_64 amd64 83INFO: User cache: /root/.sonar/cache 84INFO: SonarQube server 6.7.7 85INFO: Default locale: "en_US", source code encoding: "UTF-8" 86INFO: Publish mode 87INFO: Load global settings 88INFO: Load global settings (done) | time=61ms 89INFO: Server id: A623D34D-AWoVn6_8P1KovjAYWYot 90INFO: User cache: /root/.sonar/cache 91INFO: Load plugins index 92INFO: Load plugins index (done) | time=40ms 93INFO: Plugin [l10nzh] defines 'l10nen' as base plugin. This metadata can be removed from manifest of l10n plugins since version 5.2. 94INFO: Process project properties 95INFO: Load project repositories 96INFO: Load project repositories (done) | time=77ms 97INFO: Load quality profiles 98INFO: Load quality profiles (done) | time=25ms 99INFO: Load active rules 100INFO: Load active rules (done) | time=111ms 101INFO: Load metrics repository 102INFO: Load metrics repository (done) | time=42ms 103INFO: Project key: test1-sonar-service 104INFO: ------------- Scan test1-sonar-service 105INFO: Load server rules 106INFO: Load server rules (done) | time=83ms 107INFO: Base dir: /var/jenkins/workspace/test1-sonar-service_TEST 108INFO: Working dir: /var/jenkins/workspace/test1-sonar-service_TEST/.scannerwork 109INFO: Source paths: src 110INFO: Source encoding: UTF-8, default locale: en_US 111INFO: Index files 112INFO: 2 files indexed 113INFO: Sensor Zero Coverage Sensor 114INFO: Sensor Zero Coverage Sensor (done) | time=23ms 115INFO: Sensor CPD Block Indexer 116INFO: Sensor CPD Block Indexer (done) | time=0ms 117INFO: SCM Publisher is disabled 118INFO: Calculating CPD for 0 files 119INFO: CPD calculation finished 120INFO: Analysis report generated in 54ms, dir size=1 KB 121INFO: Analysis reports compressed in 7ms, zip size=1 KB 122INFO: Analysis report uploaded in 128ms 123INFO: ANALYSIS SUCCESSFUL, you can browse http://172.25.254.133:9000/dashboard/index/test1-sonar-service 124INFO: Note that you will be able to access the updated dashboard once the server has processed the submitted analysis report 125INFO: More about the report processing at http://172.25.254.133:9000/api/ce/task?id=AWpSENV2mO3e1qpxfNZo 126INFO: Task total time: 1.702 s 127INFO: ------------------------------------------------------------------------ 128INFO: EXECUTION SUCCESS 129INFO: ------------------------------------------------------------------------ 130INFO: Total time: 3.006s 131INFO: Final Memory: 8M/92M 132INFO: ------------------------------------------------------------------------ 133[Pipeline] } 134[Pipeline] // node 135[Pipeline] End of Pipeline 136Finished: SUCCESS