DEVOPS技术实践_06:sonar与Jenksin集成
代码质量管理平台
一、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文件
#!/usr/bin/groovy node(){
//checkout
checkout([$class: 'GitSCM',
branches: [[name: '*/master']],
doGenerateSubmoduleConfigurations: false, extensions: [],
submoduleCfg: [],
userRemoteConfigs: [[credentialsId: '87684a81-092f-4175-afff-6d9df42f2b14',
url: 'http://172.25.254.131/devops/jenkins.git']]])
//build
def mvnHome = tool 'M2_HOME'
sh "${mvnHome}/bin/mvn ${buildShell}"
}
1.7 提交代码,构建
Started by user admin
Obtained sonar.jenkinsfile from git http://172.25.254.131/devops/jenkins.git
Running in Durability level: MAX_SURVIVABILITY
[Pipeline] Start of Pipeline
[Pipeline] node
Running on Jenkins in /root/.jenkins/workspace/test1-sonar-service_TEST
[Pipeline] {
[Pipeline] checkout
using credential 87684a81-092f--afff-6d9df42f2b14
Cloning the remote Git repository
Cloning repository http://172.25.254.131/devops/jenkins.git
> git init /root/.jenkins/workspace/test1-sonar-service_TEST # timeout=
Fetching upstream changes from http://172.25.254.131/devops/jenkins.git
> git --version # timeout=
using GIT_ASKPASS to set credentials
> git fetch --tags --progress http://172.25.254.131/devops/jenkins.git +refs/heads/*:refs/remotes/origin/*
> git config remote.origin.url http://172.25.254.131/devops/jenkins.git # timeout=10
> git config --add remote.origin.fetch +refs/heads/*:refs/remotes/origin/* # timeout=10
> git config remote.origin.url http://172.25.254.131/devops/jenkins.git # timeout=10
Fetching upstream changes from http://172.25.254.131/devops/jenkins.git
using GIT_ASKPASS to set credentials
> git fetch --tags --progress http://172.25.254.131/devops/jenkins.git +refs/heads/*:refs/remotes/origin/*
> git rev-parse refs/remotes/origin/master^{commit} # timeout=10
> git rev-parse refs/remotes/origin/origin/master^{commit} # timeout=10
Checking out Revision e844e8870b03a721578cf029494ce02ce311c7fb (refs/remotes/origin/master)
> git config core.sparsecheckout # timeout=10
> git checkout -f e844e8870b03a721578cf029494ce02ce311c7fb
Commit message: "Update sonar.jenkinsfile"
First time build. Skipping changelog.
[Pipeline] tool
[Pipeline] }
[Pipeline] // node
[Pipeline] End of Pipeline
groovy.lang.MissingPropertyException: No such property: buildShell for class: groovy.lang.Binding #没有这个参数
at groovy.lang.Binding.getVariable(Binding.java:63)
at org.jenkinsci.plugins.scriptsecurity.sandbox.groovy.SandboxInterceptor.onGetProperty(SandboxInterceptor.java:264)
at org.kohsuke.groovy.sandbox.impl.Checker$6.call(Checker.java:289)
at org.kohsuke.groovy.sandbox.impl.Checker.checkedGetProperty(Checker.java:293)
at org.kohsuke.groovy.sandbox.impl.Checker.checkedGetProperty(Checker.java:269)
at com.cloudbees.groovy.cps.sandbox.SandboxInvoker.getProperty(SandboxInvoker.java:29)
at com.cloudbees.groovy.cps.impl.PropertyAccessBlock.rawGet(PropertyAccessBlock.java:20)
at WorkflowScript.run(WorkflowScript:13)
at ___cps.transform___(Native Method)
at com.cloudbees.groovy.cps.impl.PropertyishBlock$ContinuationImpl.get(PropertyishBlock.java:74)
at com.cloudbees.groovy.cps.LValueBlock$GetAdapter.receive(LValueBlock.java:30)
at com.cloudbees.groovy.cps.impl.PropertyishBlock$ContinuationImpl.fixName(PropertyishBlock.java:66)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at com.cloudbees.groovy.cps.impl.ContinuationPtr$ContinuationImpl.receive(ContinuationPtr.java:72)
at com.cloudbees.groovy.cps.impl.ConstantBlock.eval(ConstantBlock.java:21)
at com.cloudbees.groovy.cps.Next.step(Next.java:83)
at com.cloudbees.groovy.cps.Continuable$1.call(Continuable.java:174)
at com.cloudbees.groovy.cps.Continuable$1.call(Continuable.java:163)
at org.codehaus.groovy.runtime.GroovyCategorySupport$ThreadCategoryInfo.use(GroovyCategorySupport.java:129)
at org.codehaus.groovy.runtime.GroovyCategorySupport.use(GroovyCategorySupport.java:268)
at com.cloudbees.groovy.cps.Continuable.run0(Continuable.java:163)
at org.jenkinsci.plugins.workflow.cps.SandboxContinuable.access$101(SandboxContinuable.java:34)
at org.jenkinsci.plugins.workflow.cps.SandboxContinuable.lambda$run0$0(SandboxContinuable.java:59)
at org.jenkinsci.plugins.scriptsecurity.sandbox.groovy.GroovySandbox.runInSandbox(GroovySandbox.java:136)
at org.jenkinsci.plugins.workflow.cps.SandboxContinuable.run0(SandboxContinuable.java:58)
at org.jenkinsci.plugins.workflow.cps.CpsThread.runNextChunk(CpsThread.java:174)
at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup.run(CpsThreadGroup.java:347)
at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup.access$200(CpsThreadGroup.java:93)
at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup$2.call(CpsThreadGroup.java:259)
at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup$2.call(CpsThreadGroup.java:247)
at org.jenkinsci.plugins.workflow.cps.CpsVmExecutorService$2.call(CpsVmExecutorService.java:64)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at hudson.remoting.SingleLaneExecutorService$1.run(SingleLaneExecutorService.java:131)
at jenkins.util.ContextResettingExecutorService$1.run(ContextResettingExecutorService.java:28)
at jenkins.security.ImpersonatingExecutorService$1.run(ImpersonatingExecutorService.java:59)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at java.lang.Thread.run(Thread.java:748)
Finished: 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
再次构建
[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 ]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help ] 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
#!/usr/bin/groovy
node(){
//checkout
checkout([$class: 'GitSCM', branches: [[name: '*/master']],
doGenerateSubmoduleConfigurations: false,
extensions: [], submoduleCfg: [],
userRemoteConfigs: [[url: 'http://172.25.254.131/tester/mvn-test01.git']]]) //build
def mvnHome = tool 'M2_HOME'
sh "${mvnHome}/bin/mvn ${buildShell}"
}
1.11 再次构建
输出台信息
Started by user admin
Obtained sonar.jenkinsfile from git http://172.25.254.131/tester/mvn-test01.git
Running in Durability level: MAX_SURVIVABILITY
[Pipeline] Start of Pipeline
[Pipeline] node
Running on Jenkins in /root/.jenkins/workspace/test1-sonar-service_TEST
[Pipeline] {
[Pipeline] checkout
No credentials specified
> git rev-parse --is-inside-work-tree # timeout=
Fetching changes from the remote Git repository
> git config remote.origin.url http://172.25.254.131/tester/mvn-test01.git # timeout=10
Fetching upstream changes from http://172.25.254.131/tester/mvn-test01.git
> git --version # timeout=
> git fetch --tags --progress http://172.25.254.131/tester/mvn-test01.git +refs/heads/*:refs/remotes/origin/*
> git rev-parse refs/remotes/origin/master^{commit} # timeout=
> git rev-parse refs/remotes/origin/origin/master^{commit} # timeout=
Checking out Revision 7060102f73c77cbfbf9dc1d02ff0c905d17328a5 (refs/remotes/origin/master)
> git config core.sparsecheckout # timeout=
> git checkout -f 7060102f73c77cbfbf9dc1d02ff0c905d17328a5
Commit message: "Update jaja.jenkinsfile"
> git rev-list --no-walk 7060102f73c77cbfbf9dc1d02ff0c905d17328a5 # timeout=
[Pipeline] tool
[Pipeline] sh
+ /usr/local/maven/apache-maven-3.6./bin/mvn clean package -DskipTests
[INFO] Scanning for projects...
[INFO]
[INFO] ---------------------< com.example.app:maven-app >----------------------
[INFO] Building maven-app 1.3-SNAPSHOT
[INFO] --------------------------------[ jar ]---------------------------------
[INFO]
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ maven-app ---
[INFO] Deleting /root/.jenkins/workspace/test1-sonar-service_TEST/target
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ maven-app ---
[WARNING] Using platform encoding (UTF- actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] skip non existing resourceDirectory /root/.jenkins/workspace/test1-sonar-service_TEST/src/main/resources
[INFO]
[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ maven-app ---
[INFO] Changes detected - recompiling the module!
[WARNING] File encoding has not been set, using platform encoding UTF-, i.e. build is platform dependent!
[INFO] Compiling source file to /root/.jenkins/workspace/test1-sonar-service_TEST/target/classes
[INFO]
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ maven-app ---
[WARNING] Using platform encoding (UTF- actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] skip non existing resourceDirectory /root/.jenkins/workspace/test1-sonar-service_TEST/src/test/resources
[INFO]
[INFO] --- maven-compiler-plugin:3.1:testCompile (default-testCompile) @ maven-app ---
[INFO] Changes detected - recompiling the module!
[WARNING] File encoding has not been set, using platform encoding UTF-, i.e. build is platform dependent!
[INFO] Compiling source file to /root/.jenkins/workspace/test1-sonar-service_TEST/target/test-classes
[INFO]
[INFO] --- maven-surefire-plugin:2.12.:test (default-test) @ maven-app ---
[INFO] Tests are skipped.
[INFO]
[INFO] --- maven-jar-plugin:2.4:jar (default-jar) @ maven-app ---
[INFO] Building jar: /root/.jenkins/workspace/test1-sonar-service_TEST/target/maven-app-1.3-SNAPSHOT.jar
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 2.386 s
[INFO] Finished at: --17T16::+:
[INFO] ------------------------------------------------------------------------
[Pipeline] }
[Pipeline] // node
[Pipeline] End of Pipeline
Finished: 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
export SONAR_SCANNER=/usr/local/sonar-scanner
export PATH=$PATH:$JAVA_HOME/bin:$SONAR_SCANNER/bin
[root@jenkins-master ~]# source /etc/profile
这里使用sonnar命令完成
6f7a4c06ef06a8be9799097024c8f2f6fe2fafe7
2.2 修改sonar.kenjinsfile文件
#!/usr/bin/groovy node(){
//checkout
checkout([$class: 'GitSCM', branches: [[name: '*/master']],
doGenerateSubmoduleConfigurations: false,
extensions: [], submoduleCfg: [],
userRemoteConfigs: [[url: 'http://172.25.254.131/tester/mvn-test01.git']]]) //build
def mvnHome = tool 'M2_HOME'
sh "${mvnHome}/bin/mvn ${buildShell}" //Sonar
sh """
sonar-scanner \
-Dsonar.projectKey=${serviceName} \
-Dsonar.projectName=${serviceName} \
-Dsonar.login=6f7a4c06ef06a8be9799097024c8f2f6fe2fafe7 \
-Dsonar.source=src
-Dsonar.host.url=${sonarServer} \
"""
}
2.3 尝试构建修改
开始构建
结果信息
[Pipeline] sh
+ sonar-scanner -Dsonar.projectKey=test1-sonar-service -Dsonar.projectName=test1-sonar-service -Dsonar.login=6f7a4c06ef06a8be9799097024c8f2f6fe2fafe7 -Dsonar.host.url=src
/root/.jenkins/workspace/test1-sonar-service_TEST@tmp/durable-f84d04fc/script.sh: line : sonar-scanner: command not found
[Pipeline] }
[Pipeline] // node
[Pipeline] End of Pipeline
ERROR: script returned exit code
Finished: FAILURE
修改
#!/usr/bin/groovy node(){
//checkout
checkout([$class: 'GitSCM', branches: [[name: '*/master']],
doGenerateSubmoduleConfigurations: false,
extensions: [], submoduleCfg: [],
userRemoteConfigs: [[url: 'http://172.25.254.131/tester/mvn-test01.git']]]) //build
def mvnHome = tool 'M2_HOME'
sh "${mvnHome}/bin/mvn ${buildShell}" //Sonar
sh """
/usr/local/sonar-scanner/bin/sonar-scanner \
-Dsonar.projectKey=${serviceName} \
-Dsonar.projectName=${serviceName} \
-Dsonar.login=6f7a4c06ef06a8be9799097024c8f2f6fe2fafe7 \
-Dsonar.source=src
-Dsonar.host.url=${sonarServer} \
-Dsonar.java.binaries=/root/.jenkins/workspace/test1-sonar-service_TEST/target/classes \
"""
}
构建
INFO: ------------------------------------------------------------------------
ERROR: Error during SonarQube Scanner execution
ERROR: You must define the following mandatory properties for 'test1-sonar-service': sonar.sources
ERROR:
ERROR: Re-run SonarQube Scanner using the -X switch to enable full debug logging.
[Pipeline] }
[Pipeline] // node
[Pipeline] End of Pipeline
ERROR: script returned exit code
Finished: FAILURE
修改:
#!/usr/bin/groovy node(){
//checkout
checkout([$class: 'GitSCM', branches: [[name: '*/master']],
doGenerateSubmoduleConfigurations: false,
extensions: [], submoduleCfg: [],
userRemoteConfigs: [[url: 'http://172.25.254.131/tester/mvn-test01.git']]]) //build
def mvnHome = tool 'M2_HOME'
sh "${mvnHome}/bin/mvn ${buildShell}" //Sonar
sh """
/usr/local/sonar-scanner/bin/sonar-scanner \
-Dsonar.projectKey=${serviceName} \
-Dsonar.projectName=${serviceName} \
-Dsonar.login=6f7a4c06ef06a8be9799097024c8f2f6fe2fafe7 \
-Dsonar.sources=src \
-Dsonar.host.url=${sonarServer} \ """
}
再次构建
Started by user admin
Obtained sonar.jenkinsfile from git http://172.25.254.131/tester/mvn-test01.git
Running in Durability level: MAX_SURVIVABILITY
[Pipeline] Start of Pipeline
[Pipeline] node
Running on Jenkins in /root/.jenkins/workspace/test1-sonar-service_TEST
[Pipeline] {
[Pipeline] checkout
No credentials specified
> git rev-parse --is-inside-work-tree # timeout=
Fetching changes from the remote Git repository
> git config remote.origin.url http://172.25.254.131/tester/mvn-test01.git # timeout=10
Fetching upstream changes from http://172.25.254.131/tester/mvn-test01.git
> git --version # timeout=
> git fetch --tags --progress http://172.25.254.131/tester/mvn-test01.git +refs/heads/*:refs/remotes/origin/*
> git rev-parse refs/remotes/origin/master^{commit} # timeout=
> git rev-parse refs/remotes/origin/origin/master^{commit} # timeout=
Checking out Revision ad3e34fe85103fdf2229159cf14e8f17493b799a (refs/remotes/origin/master)
> git config core.sparsecheckout # timeout=
> git checkout -f ad3e34fe85103fdf2229159cf14e8f17493b799a
Commit message: "Update sonar.jenkinsfile"
> git rev-list --no-walk d57ef66ee0b2a069a63da5fe6afc2b1c7d276e67 # timeout=
[Pipeline] tool
[Pipeline] sh
+ /usr/local/maven/apache-maven-3.6./bin/mvn clean package -DskipTests
[INFO] Scanning for projects...
[INFO]
[INFO] ---------------------< com.example.app:maven-app >----------------------
[INFO] Building maven-app 1.3-SNAPSHOT
[INFO] --------------------------------[ jar ]---------------------------------
[INFO]
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ maven-app ---
[INFO] Deleting /root/.jenkins/workspace/test1-sonar-service_TEST/target
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ maven-app ---
[WARNING] Using platform encoding (UTF- actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] skip non existing resourceDirectory /root/.jenkins/workspace/test1-sonar-service_TEST/src/main/resources
[INFO]
[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ maven-app ---
[INFO] Changes detected - recompiling the module!
[WARNING] File encoding has not been set, using platform encoding UTF-, i.e. build is platform dependent!
[INFO] Compiling source file to /root/.jenkins/workspace/test1-sonar-service_TEST/target/classes
[INFO]
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ maven-app ---
[WARNING] Using platform encoding (UTF- actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] skip non existing resourceDirectory /root/.jenkins/workspace/test1-sonar-service_TEST/src/test/resources
[INFO]
[INFO] --- maven-compiler-plugin:3.1:testCompile (default-testCompile) @ maven-app ---
[INFO] Changes detected - recompiling the module!
[WARNING] File encoding has not been set, using platform encoding UTF-, i.e. build is platform dependent!
[INFO] Compiling source file to /root/.jenkins/workspace/test1-sonar-service_TEST/target/test-classes
[INFO]
[INFO] --- maven-surefire-plugin:2.12.:test (default-test) @ maven-app ---
[INFO] Tests are skipped.
[INFO]
[INFO] --- maven-jar-plugin:2.4:jar (default-jar) @ maven-app ---
[INFO] Building jar: /root/.jenkins/workspace/test1-sonar-service_TEST/target/maven-app-1.3-SNAPSHOT.jar
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 4.356 s
[INFO] Finished at: --20T02::+:
[INFO] ------------------------------------------------------------------------
[Pipeline] sh
+ /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
INFO: Scanner configuration file: /usr/local/sonar-scanner/conf/sonar-scanner.properties
INFO: Project root configuration file: NONE
INFO: SonarQube Scanner 3.3.0.1492
INFO: Java 1.8.0_121 Oracle Corporation (-bit)
INFO: Linux 3.10.-.el7.x86_64 amd64
INFO: User cache: /root/.sonar/cache
INFO: SonarQube server 6.7.
INFO: Default locale: "en_US", source code encoding: "UTF-8"
INFO: Publish mode
INFO: Load global settings
INFO: Load global settings (done) | time=57ms
INFO: Server id: A623D34D-AWoVn6_8P1KovjAYWYot
INFO: User cache: /root/.sonar/cache
INFO: Load plugins index
INFO: Load plugins index (done) | time=136ms
INFO: Plugin [l10nzh] defines 'l10nen' as base plugin. This metadata can be removed from manifest of l10n plugins since version 5.2.
INFO: Process project properties
INFO: Load project repositories
INFO: Load project repositories (done) | time=13ms
INFO: Load quality profiles
INFO: Load quality profiles (done) | time=36ms
INFO: Load active rules
INFO: Load active rules (done) | time=290ms
INFO: Load metrics repository
INFO: Load metrics repository (done) | time=39ms
INFO: Project key: test1-sonar-service
INFO: ------------- Scan test1-sonar-service
INFO: Load server rules
INFO: Load server rules (done) | time=23ms
INFO: Base dir: /root/.jenkins/workspace/test1-sonar-service_TEST
INFO: Working dir: /root/.jenkins/workspace/test1-sonar-service_TEST/.scannerwork
INFO: Source paths: src
INFO: Source encoding: UTF-, default locale: en_US
INFO: Index files
INFO: files indexed
INFO: Sensor Zero Coverage Sensor
INFO: Sensor Zero Coverage Sensor (done) | time=9ms
INFO: Sensor CPD Block Indexer
INFO: Sensor CPD Block Indexer (done) | time=0ms
INFO: SCM Publisher is disabled
INFO: Calculating CPD for files
INFO: CPD calculation finished
INFO: Analysis report generated in 49ms, dir size= KB
INFO: Analysis reports compressed in 6ms, zip size= KB
INFO: Analysis report uploaded in 442ms
INFO: ANALYSIS SUCCESSFUL, you can browse http://172.25.254.133:9000/dashboard/index/test1-sonar-service
INFO: Note that you will be able to access the updated dashboard once the server has processed the submitted analysis report
INFO: More about the report processing at http://172.25.254.133:9000/api/ce/task?id=AWpPClxumO3e1qpxfNZm
INFO: Task total time: 1.776 s
INFO: ------------------------------------------------------------------------
INFO: EXECUTION SUCCESS
INFO: ------------------------------------------------------------------------
INFO: Total time: .104s
INFO: Final Memory: 8M/129M
INFO: ------------------------------------------------------------------------
[Pipeline] }
[Pipeline] // node
[Pipeline] End of Pipeline
Finished: SUCCESS
完成
三、使用slave
3.1 在任务配置加一个选项参数
sonar.jenkinsfile文件
#!/usr/bin/groovy node("${nodeSlave}"){
//checkout
checkout([$class: 'GitSCM', branches: [[name: '*/master']],
doGenerateSubmoduleConfigurations: false,
extensions: [], submoduleCfg: [],
userRemoteConfigs: [[url: 'http://172.25.254.131/tester/mvn-test01.git']]]) //build
def mvnHome = tool 'M2_HOME'
sh "${mvnHome}/bin/mvn ${buildShell}"}
[root@jenkins-master ~]# scp -r /usr/local/sonar-scanner 172.25.254.134:/usr/local/
[root@node5 ~]# vim /etc/profile
export SONAR_SCANNER=/usr/local/sonar-scanner
export PATH=$PATH:$SONAR_SCANNER/bin
[root@node5 ~]# source /etc/profile
执行构建的时候,会一直报错
[Pipeline] tool
[Pipeline] sh
+ /usr/local/maven/apache-maven-3.6./bin/mvn clean package -DskipTests
The JAVA_HOME environment variable is not defined correctly
This environment variable is needed to run this program
NB: JAVA_HOME should point to a JDK not a JRE
[Pipeline] }
[Pipeline] // node
[Pipeline] End of Pipeline
ERROR: script returned exit code
Finished: FAILURE
然后在salve1节点一直排查,jdk的环境变量没有问题,mvn -v执行正常,
[root@node5 test1-sonar-service_TEST]# /usr/local/maven/apache-maven-3.6.1/bin/mvn clean package -DskipTests也执行成功
[INFO] Scanning for projects...
[INFO]
[INFO] ---------------------< com.example.app:maven-app >----------------------
[INFO] Building maven-app 1.3-SNAPSHOT
[INFO] --------------------------------[ jar ]---------------------------------
[INFO]
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ maven-app ---
[INFO] Deleting /var/jenkins/workspace/test1-sonar-service_TEST/target
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ maven-app ---
[WARNING] Using platform encoding (UTF- actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] skip non existing resourceDirectory /var/jenkins/workspace/test1-sonar-service_TEST/src/main/resources
[INFO]
[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ maven-app ---
[INFO] Changes detected - recompiling the module!
[WARNING] File encoding has not been set, using platform encoding UTF-, i.e. build is platform dependent!
[INFO] Compiling source file to /var/jenkins/workspace/test1-sonar-service_TEST/target/classes
[INFO]
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ maven-app ---
[WARNING] Using platform encoding (UTF- actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] skip non existing resourceDirectory /var/jenkins/workspace/test1-sonar-service_TEST/src/test/resources
[INFO]
[INFO] --- maven-compiler-plugin:3.1:testCompile (default-testCompile) @ maven-app ---
[INFO] Changes detected - recompiling the module!
[WARNING] File encoding has not been set, using platform encoding UTF-, i.e. build is platform dependent!
[INFO] Compiling source file to /var/jenkins/workspace/test1-sonar-service_TEST/target/test-classes
[INFO]
[INFO] --- maven-surefire-plugin:2.12.:test (default-test) @ maven-app ---
[INFO] Tests are skipped.
[INFO]
[INFO] --- maven-jar-plugin:2.4:jar (default-jar) @ maven-app ---
[INFO] Building jar: /var/jenkins/workspace/test1-sonar-service_TEST/target/maven-app-1.3-SNAPSHOT.jar
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 2.030 s
[INFO] Finished at: --24T23::+:
但是构建一直失败,卡了三四个小时,后来重启了master和slave节点,再一次构建执行成功,是个大坑
成功输出结果
Started by user admin
Obtained sonar.jenkinsfile from git http://172.25.254.131/tester/mvn-test01.git
Running in Durability level: MAX_SURVIVABILITY
[Pipeline] Start of Pipeline
[Pipeline] node
Running on slave1 in /var/jenkins/workspace/test1-sonar-service_TEST@
[Pipeline] {
[Pipeline] checkout
No credentials specified
Fetching changes from the remote Git repository
> git rev-parse --is-inside-work-tree # timeout=
> git config remote.origin.url http://172.25.254.131/tester/mvn-test01.git # timeout=10
Fetching upstream changes from http://172.25.254.131/tester/mvn-test01.git
> git --version # timeout=
> git fetch --tags --progress http://172.25.254.131/tester/mvn-test01.git +refs/heads/*:refs/remotes/origin/*
Checking out Revision 401249b8852695b6c9e1ed1cfea359101daffab4 (refs/remotes/origin/master)
> git rev-parse refs/remotes/origin/master^{commit} # timeout=
> git rev-parse refs/remotes/origin/origin/master^{commit} # timeout=
> git config core.sparsecheckout # timeout=
> git checkout -f 401249b8852695b6c9e1ed1cfea359101daffab4
Commit message: "Update sonar.jenkinsfile"
[Pipeline] tool
[Pipeline] sh
> git rev-list --no-walk 401249b8852695b6c9e1ed1cfea359101daffab4 # timeout=
+ /usr/local/maven/apache-maven-3.6./bin/mvn clean package -DskipTests
[INFO] Scanning for projects...
[INFO]
[INFO] ---------------------< com.example.app:maven-app >----------------------
[INFO] Building maven-app 1.3-SNAPSHOT
[INFO] --------------------------------[ jar ]---------------------------------
[INFO]
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ maven-app ---
[INFO] Deleting /var/jenkins/workspace/test1-sonar-service_TEST@/target
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ maven-app ---
[WARNING] Using platform encoding (UTF- actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] skip non existing resourceDirectory /var/jenkins/workspace/test1-sonar-service_TEST@/src/main/resources
[INFO]
[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ maven-app ---
[INFO] Changes detected - recompiling the module!
[WARNING] File encoding has not been set, using platform encoding UTF-, i.e. build is platform dependent!
[INFO] Compiling source file to /var/jenkins/workspace/test1-sonar-service_TEST@/target/classes
[INFO]
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ maven-app ---
[WARNING] Using platform encoding (UTF- actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] skip non existing resourceDirectory /var/jenkins/workspace/test1-sonar-service_TEST@/src/test/resources
[INFO]
[INFO] --- maven-compiler-plugin:3.1:testCompile (default-testCompile) @ maven-app ---
[INFO] Changes detected - recompiling the module!
[WARNING] File encoding has not been set, using platform encoding UTF-, i.e. build is platform dependent!
[INFO] Compiling source file to /var/jenkins/workspace/test1-sonar-service_TEST@/target/test-classes
[INFO]
[INFO] --- maven-surefire-plugin:2.12.:test (default-test) @ maven-app ---
[INFO] Tests are skipped.
[INFO]
[INFO] --- maven-jar-plugin:2.4:jar (default-jar) @ maven-app ---
[INFO] Building jar: /var/jenkins/workspace/test1-sonar-service_TEST@/target/maven-app-1.3-SNAPSHOT.jar
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 6.972 s
[INFO] Finished at: --24T23::+:
[INFO] ------------------------------------------------------------------------
[Pipeline] }
[Pipeline] // node
[Pipeline] End of Pipeline
Finished: SUCCESS
3.2 结合sonar
修改sonar.jenkinsfile
#!/usr/bin/groovy node("${nodeSlave}"){
//checkout
checkout([$class: 'GitSCM', branches: [[name: '*/master']],
doGenerateSubmoduleConfigurations: false,
extensions: [], submoduleCfg: [],
userRemoteConfigs: [[url: 'http://172.25.254.131/tester/mvn-test01.git']]]) //build
def mvnHome = tool 'M2_HOME'
sh "${mvnHome}/bin/mvn ${buildShell}" //Sonar
sh """
/usr/local/sonar-scanner/bin/sonar-scanner \
-Dsonar.projectKey=${serviceName} \
-Dsonar.projectName=${serviceName} \
-Dsonar.login=6f7a4c06ef06a8be9799097024c8f2f6fe2fafe7 \
-Dsonar.sources=src \
-Dsonar.host.url=${sonarServer} \ """
}
构建也顺利完成
Started by user admin
Obtained sonar.jenkinsfile from git http://172.25.254.131/tester/mvn-test01.git
Running in Durability level: MAX_SURVIVABILITY
[Pipeline] Start of Pipeline
[Pipeline] node
Running on slave1 in /var/jenkins/workspace/test1-sonar-service_TEST
[Pipeline] {
[Pipeline] checkout
No credentials specified
Fetching changes from the remote Git repository
Checking out Revision da77bf327b6d4c057ba469fdd5189f78ab6d850c (refs/remotes/origin/master)
> git rev-parse --is-inside-work-tree # timeout=
> git config remote.origin.url http://172.25.254.131/tester/mvn-test01.git # timeout=10
Fetching upstream changes from http://172.25.254.131/tester/mvn-test01.git
> git --version # timeout=
> git fetch --tags --progress http://172.25.254.131/tester/mvn-test01.git +refs/heads/*:refs/remotes/origin/*
> git rev-parse refs/remotes/origin/master^{commit} # timeout=
> git rev-parse refs/remotes/origin/origin/master^{commit} # timeout=
Commit message: "Update sonar.jenkinsfile"
[Pipeline] tool
[Pipeline] sh
+ /usr/local/maven/apache-maven-3.6./bin/mvn clean package -DskipTests
> git config core.sparsecheckout # timeout=
> git checkout -f da77bf327b6d4c057ba469fdd5189f78ab6d850c
> git rev-list --no-walk 401249b8852695b6c9e1ed1cfea359101daffab4 # timeout=
[INFO] Scanning for projects...
[INFO]
[INFO] ---------------------< com.example.app:maven-app >----------------------
[INFO] Building maven-app 1.3-SNAPSHOT
[INFO] --------------------------------[ jar ]---------------------------------
[INFO]
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ maven-app ---
[INFO] Deleting /var/jenkins/workspace/test1-sonar-service_TEST/target
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ maven-app ---
[WARNING] Using platform encoding (UTF- actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] skip non existing resourceDirectory /var/jenkins/workspace/test1-sonar-service_TEST/src/main/resources
[INFO]
[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ maven-app ---
[INFO] Changes detected - recompiling the module!
[WARNING] File encoding has not been set, using platform encoding UTF-, i.e. build is platform dependent!
[INFO] Compiling source file to /var/jenkins/workspace/test1-sonar-service_TEST/target/classes
[INFO]
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ maven-app ---
[WARNING] Using platform encoding (UTF- actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] skip non existing resourceDirectory /var/jenkins/workspace/test1-sonar-service_TEST/src/test/resources
[INFO]
[INFO] --- maven-compiler-plugin:3.1:testCompile (default-testCompile) @ maven-app ---
[INFO] Changes detected - recompiling the module!
[WARNING] File encoding has not been set, using platform encoding UTF-, i.e. build is platform dependent!
[INFO] Compiling source file to /var/jenkins/workspace/test1-sonar-service_TEST/target/test-classes
[INFO]
[INFO] --- maven-surefire-plugin:2.12.:test (default-test) @ maven-app ---
[INFO] Tests are skipped.
[INFO]
[INFO] --- maven-jar-plugin:2.4:jar (default-jar) @ maven-app ---
[INFO] Building jar: /var/jenkins/workspace/test1-sonar-service_TEST/target/maven-app-1.3-SNAPSHOT.jar
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 2.938 s
[INFO] Finished at: --25T00::+:
[INFO] ------------------------------------------------------------------------
[Pipeline] sh
+ /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
INFO: Scanner configuration file: /usr/local/sonar-scanner/conf/sonar-scanner.properties
INFO: Project root configuration file: NONE
INFO: SonarQube Scanner 3.3.0.1492
INFO: Java 1.8.0_121 Oracle Corporation (-bit)
INFO: Linux 3.10.-.el7.x86_64 amd64
INFO: User cache: /root/.sonar/cache
INFO: SonarQube server 6.7.
INFO: Default locale: "en_US", source code encoding: "UTF-8"
INFO: Publish mode
INFO: Load global settings
INFO: Load global settings (done) | time=172ms
INFO: Server id: A623D34D-AWoVn6_8P1KovjAYWYot
INFO: User cache: /root/.sonar/cache
INFO: Load plugins index
INFO: Load plugins index (done) | time=340ms
INFO: Download sonar-l10n-zh-plugin-1.19.jar
INFO: Plugin [l10nzh] defines 'l10nen' as base plugin. This metadata can be removed from manifest of l10n plugins since version 5.2.
INFO: Download sonar-python-plugin-1.13.0.2922.jar
INFO: Process project properties
INFO: Load project repositories
INFO: Load project repositories (done) | time=59ms
INFO: Load quality profiles
INFO: Load quality profiles (done) | time=21ms
INFO: Load active rules
INFO: Load active rules (done) | time=81ms
INFO: Load metrics repository
INFO: Load metrics repository (done) | time=27ms
INFO: Project key: test1-sonar-service
INFO: ------------- Scan test1-sonar-service
INFO: Load server rules
INFO: Load server rules (done) | time=62ms
INFO: Base dir: /var/jenkins/workspace/test1-sonar-service_TEST
INFO: Working dir: /var/jenkins/workspace/test1-sonar-service_TEST/.scannerwork
INFO: Source paths: src
INFO: Source encoding: UTF-, default locale: en_US
INFO: Index files
INFO: files indexed
INFO: Sensor Zero Coverage Sensor
INFO: Sensor Zero Coverage Sensor (done) | time=11ms
INFO: Sensor CPD Block Indexer
INFO: Sensor CPD Block Indexer (done) | time=0ms
INFO: SCM Publisher is disabled
INFO: Calculating CPD for files
INFO: CPD calculation finished
INFO: Analysis report generated in 46ms, dir size= KB
INFO: Analysis reports compressed in 4ms, zip size= KB
INFO: Analysis report uploaded in 40ms
INFO: ANALYSIS SUCCESSFUL, you can browse http://172.25.254.133:9000/dashboard/index/test1-sonar-service
INFO: Note that you will be able to access the updated dashboard once the server has processed the submitted analysis report
INFO: More about the report processing at http://172.25.254.133:9000/api/ce/task?id=AWpQF7VgmO3e1qpxfNZn
INFO: Task total time: 1.585 s
INFO: ------------------------------------------------------------------------
INFO: EXECUTION SUCCESS
INFO: ------------------------------------------------------------------------
INFO: Total time: .742s
INFO: Final Memory: 12M/90M
INFO: ------------------------------------------------------------------------
[Pipeline] }
[Pipeline] // node
[Pipeline] End of Pipeline
Finished: SUCCESS
四、现有优化
4.1 修改sonar.jenkinsfile
#!/usr/bin/groovy String skipSonar = "${env.skipSonar}"
String skipTset = "${env.skipTest}" node("${nodeSlave}"){
//checkout
stage 'checkout'
checkout([$class: 'GitSCM', branches: [[name: '*/master']],
doGenerateSubmoduleConfigurations: false,
extensions: [], submoduleCfg: [],
userRemoteConfigs: [[url: 'http://172.25.254.131/tester/mvn-test01.git']]])
//build
stage 'Build'
if ("${skipTest}" == 'true'){
mvnHome = tool 'M2_HOME'
sh "${mvnHome}/bin/mvn ${buildShell} -DskipTests"
}
else{
sh "${mvnHome}/bin/mvn ${buildShell}"
} //Sonar
stage 'Sonar'
sh """
/usr/local/sonar-scanner/bin/sonar-scanner \
-Dsonar.projectKey=${serviceName} \
-Dsonar.projectName=${serviceName} \
-Dsonar.login=6f7a4c06ef06a8be9799097024c8f2f6fe2fafe7 \
-Dsonar.sources=src \
-Dsonar.host.url=${sonarServer} \ """
}
4.2 jenkins加几个开关
任务配置
4.3 开始构建
4.4 执行结果
Started by user admin
Obtained sonar.jenkinsfile from git http://172.25.254.131/tester/mvn-test01.git
Running in Durability level: MAX_SURVIVABILITY
[Pipeline] Start of Pipeline
[Pipeline] node
Running on slave1 in /var/jenkins/workspace/test1-sonar-service_TEST
[Pipeline] {
[Pipeline] stage (checkout)
Using the ‘stage’ step without a block argument is deprecated
Entering stage checkout
Proceeding
[Pipeline] checkout
No credentials specified
Fetching changes from the remote Git repository
Checking out Revision ae3a97f638dd6827893927b958f0996c810a5b5c (refs/remotes/origin/master)
Commit message: "Update sonar.jenkinsfile"
[Pipeline] stage (Build)
Using the ‘stage’ step without a block argument is deprecated
Entering stage Build
Proceeding
[Pipeline] tool
[Pipeline] sh
+ /usr/local/maven/apache-maven-3.6./bin/mvn clean package -DskipTests
> git rev-parse --is-inside-work-tree # timeout=
> git config remote.origin.url http://172.25.254.131/tester/mvn-test01.git # timeout=10
Fetching upstream changes from http://172.25.254.131/tester/mvn-test01.git
> git --version # timeout=
> git fetch --tags --progress http://172.25.254.131/tester/mvn-test01.git +refs/heads/*:refs/remotes/origin/*
> git rev-parse refs/remotes/origin/master^{commit} # timeout=
> git rev-parse refs/remotes/origin/origin/master^{commit} # timeout=
> git config core.sparsecheckout # timeout=
> git checkout -f ae3a97f638dd6827893927b958f0996c810a5b5c
> git rev-list --no-walk 08386a6b4836d2e277eca119c1651df0158ed964 # timeout=
[INFO] Scanning for projects...
[INFO]
[INFO] ---------------------< com.example.app:maven-app >----------------------
[INFO] Building maven-app 1.3-SNAPSHOT
[INFO] --------------------------------[ jar ]---------------------------------
[INFO]
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ maven-app ---
[INFO] Deleting /var/jenkins/workspace/test1-sonar-service_TEST/target
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ maven-app ---
[WARNING] Using platform encoding (UTF- actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] skip non existing resourceDirectory /var/jenkins/workspace/test1-sonar-service_TEST/src/main/resources
[INFO]
[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ maven-app ---
[INFO] Changes detected - recompiling the module!
[WARNING] File encoding has not been set, using platform encoding UTF-, i.e. build is platform dependent!
[INFO] Compiling source file to /var/jenkins/workspace/test1-sonar-service_TEST/target/classes
[INFO]
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ maven-app ---
[WARNING] Using platform encoding (UTF- actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] skip non existing resourceDirectory /var/jenkins/workspace/test1-sonar-service_TEST/src/test/resources
[INFO]
[INFO] --- maven-compiler-plugin:3.1:testCompile (default-testCompile) @ maven-app ---
[INFO] Changes detected - recompiling the module!
[WARNING] File encoding has not been set, using platform encoding UTF-, i.e. build is platform dependent!
[INFO] Compiling source file to /var/jenkins/workspace/test1-sonar-service_TEST/target/test-classes
[INFO]
[INFO] --- maven-surefire-plugin:2.12.:test (default-test) @ maven-app ---
[INFO] Tests are skipped.
[INFO]
[INFO] --- maven-jar-plugin:2.4:jar (default-jar) @ maven-app ---
[INFO] Building jar: /var/jenkins/workspace/test1-sonar-service_TEST/target/maven-app-1.3-SNAPSHOT.jar
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 2.321 s
[INFO] Finished at: --25T09::+:
[INFO] ------------------------------------------------------------------------
[Pipeline] stage (Sonar)
Using the ‘stage’ step without a block argument is deprecated
Entering stage Sonar
Proceeding
[Pipeline] sh
+ /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
INFO: Scanner configuration file: /usr/local/sonar-scanner/conf/sonar-scanner.properties
INFO: Project root configuration file: NONE
INFO: SonarQube Scanner 3.3.0.1492
INFO: Java 1.8.0_121 Oracle Corporation (-bit)
INFO: Linux 3.10.-.el7.x86_64 amd64
INFO: User cache: /root/.sonar/cache
INFO: SonarQube server 6.7.
INFO: Default locale: "en_US", source code encoding: "UTF-8"
INFO: Publish mode
INFO: Load global settings
INFO: Load global settings (done) | time=61ms
INFO: Server id: A623D34D-AWoVn6_8P1KovjAYWYot
INFO: User cache: /root/.sonar/cache
INFO: Load plugins index
INFO: Load plugins index (done) | time=40ms
INFO: Plugin [l10nzh] defines 'l10nen' as base plugin. This metadata can be removed from manifest of l10n plugins since version 5.2.
INFO: Process project properties
INFO: Load project repositories
INFO: Load project repositories (done) | time=77ms
INFO: Load quality profiles
INFO: Load quality profiles (done) | time=25ms
INFO: Load active rules
INFO: Load active rules (done) | time=111ms
INFO: Load metrics repository
INFO: Load metrics repository (done) | time=42ms
INFO: Project key: test1-sonar-service
INFO: ------------- Scan test1-sonar-service
INFO: Load server rules
INFO: Load server rules (done) | time=83ms
INFO: Base dir: /var/jenkins/workspace/test1-sonar-service_TEST
INFO: Working dir: /var/jenkins/workspace/test1-sonar-service_TEST/.scannerwork
INFO: Source paths: src
INFO: Source encoding: UTF-, default locale: en_US
INFO: Index files
INFO: files indexed
INFO: Sensor Zero Coverage Sensor
INFO: Sensor Zero Coverage Sensor (done) | time=23ms
INFO: Sensor CPD Block Indexer
INFO: Sensor CPD Block Indexer (done) | time=0ms
INFO: SCM Publisher is disabled
INFO: Calculating CPD for files
INFO: CPD calculation finished
INFO: Analysis report generated in 54ms, dir size= KB
INFO: Analysis reports compressed in 7ms, zip size= KB
INFO: Analysis report uploaded in 128ms
INFO: ANALYSIS SUCCESSFUL, you can browse http://172.25.254.133:9000/dashboard/index/test1-sonar-service
INFO: Note that you will be able to access the updated dashboard once the server has processed the submitted analysis report
INFO: More about the report processing at http://172.25.254.133:9000/api/ce/task?id=AWpSENV2mO3e1qpxfNZo
INFO: Task total time: 1.702 s
INFO: ------------------------------------------------------------------------
INFO: EXECUTION SUCCESS
INFO: ------------------------------------------------------------------------
INFO: Total time: .006s
INFO: Final Memory: 8M/92M
INFO: ------------------------------------------------------------------------
[Pipeline] }
[Pipeline] // node
[Pipeline] End of Pipeline
Finished: SUCCESS
DEVOPS技术实践_06:sonar与Jenksin集成的更多相关文章
- DEVOPS技术实践_11:Jenkins集成Sonar
前言 前面已经有介绍sonar的安装,简单应用,下面在简答的研究一下sonar和jenkins集成的简单使用,对于sonar的安装不做介绍 一 sonar的简单介绍 持续检查避免了低质量的代码,比如S ...
- DEVOPS技术实践_12:创建持续集成的管道
持续集成不仅包含了Jenkins或者相关其它的CI工具,也包含了包含代码如何控制,采用的什么分支策略等.不同的组织可能采用不同的类型的策略来完成CI,策略类型和项目的类型的有很大的关系. 一 分支策略 ...
- DEVOPS技术实践_05:sonar静态代码扫描
一.SonarQube静态代码扫描平台 1.1 安装 https://www.sonarqube.org/官网 1.2 下载软件包 https://www.sonarqube.org/download ...
- DEVOPS技术实践_01:jenkins集成平台
一.准备环境 准备三台机器 角色 IP地址 用户名 密码 jenkins-master 172.25.254.130 admin meiyoumima gitlab 172.25.254 ...
- DEVOPS技术实践_13:使用Jenkins持续传送设计-CD基础
1. 分支策略 持续集成中使用的分支策略包括以下三个: The master branch The integration branch The feature branch 而CD只在Integra ...
- DEVOPS技术实践_10:安装部署Artifactory
需要一种机制去存储所有的二进制代码(build,packages,third-party plugins等)到类似于版本控制系统的系统. 像Git,SVN存储代码,它们存储的往往是源代码,不是二进制文 ...
- DEVOPS技术实践_04:Jenkins参数化构建
一.参数化构建 1.1 各个参数的信息 凭据参数存储一个用户的账号密码信息,等等,运用最多的是选项参数 1.2 使用选项参数 构建已经变成参数化构建 1.3 获取这个值,修改Jenkinsfile文件 ...
- DEVOPS技术实践_03:Jenkins自动构建
一.提交代码自动构建 当开发人员在gitlab提交代码后,会自动触发jenkin构建 点击项目---->点击diy_maven-TEST----->点击配置--->构建触发器---- ...
- DEVOPS技术实践_23:判断文件下载成功作为执行条件
在实际生产中,我们经常会需要通过判断一个结果作为一个条件去执行另一个内容,比如判断一个文件是否存在,判官一个命令是否执行成功等等 现在我们选择其中一个场景进行实验,当某个目录下存在,则执行操作 1. ...
随机推荐
- Java练习 SDUT-1588_圆的面积
圆的面积 Time Limit: 1000 ms Memory Limit: 32768 KiB Problem Description Give you the radius of a circle ...
- JavaScript 开发者都应该知道的十个概念
1. 原始值和引用值(Value vs. Reference) 理解对象.数组和函数是如何复制和传递到函数中的.了解引用值是被复制了什么,理解原始值是通过复制值来进行复制和传递的. 简析:ECMASc ...
- oracle函数 LPAD(c1,n[,c2])
[功能]在字符串c1的左边用字符串c2填充,直到长度为n时为止 [参数]C1 字符串 n 追加后字符总长度 c2 追加字符串,默认为空格 [返回]字符型 [说明]如果c1长度大于n,则返回c1左边n个 ...
- @bzoj - 2388@ 旅行规划
目录 @description@ @solution@ @accepted code@ @details@ @description@ 请你维护一个序列,支持两种操作: (1)某个区间 [x, y] ...
- Sublime插件:增强篇
Sublime Text 如何安装插件详见:https://packagecontrol.io/installation WordCount:可以实时显示当前文件的字数. 安装后,后下角多出字数 En ...
- adblock自定义规则
click.admaster.cn/* cm.baidu.com/* cm.pos.baidu.com/* cpro.baidu.com/* cpro.baidustatic.com/* dup.ba ...
- hdu 1289 Hat’s IEEE
Problem - 1289 好题.其实就是模拟IEEE754的格式,不过要注意的是,这里用的32位是float,用double就不对了. 代码如下: #include <cstdio> ...
- px em rem %作为单位使用
博客地址 :https://www.cnblogs.com/sandraryan/ px 我们都很熟悉啦,但是固定大小无法适配各种屏幕. rem是CSS3新增的一个相对单位(root em,根em), ...
- Python:pip 和pip3的区别
前言 装完python3后发现库里面既有pip也有pip3,不知道它们的区别,因此特意去了解了一下. 解释 先搜索了一下看到了如下的解释, 安装了python3之后,库里面既会有pip3也会有pip ...
- Unity 鼠标控制视角功能和动画播放冲突解决办法
环境是 unity 5.6.4 情况说明: 1 模型动画单独播放是没问题的. 2 鼠标控制模型是没问题的. 3 在start中播放模型动画,即使鼠标控制视角代码还挂载着,但是模型却无法用鼠标旋转等操作 ...