1下載jacoco,並上傳至服務器:https://www.eclemma.org/jacoco/html
2.應用服務tomcat的catalina.sh增長jacocoagentjava
#JAVA_OPTS="$JAVA_OPTS -javaagent:/Users/qiaojiafei/Documents/work/jacoco/jacoco-0.8.3/lib/jacocoagent.jar=includes=*,classdumpdir=classes,output=tcpserver,address=127.0.0.1,port=6300"
2.jenkins的pipeline配置node
node { stage('Test') { echo 'This is a test step' checkout poll: false, scm: [$class: 'GitSCM', branches: [[name: '*/develop']], doGenerateSubmoduleConfigurations: false, extensions: [], submoduleCfg: [], userRemoteConfigs: [[credentialsId: 'bad9f924--4416-9f5e-', url: 'http://:8000/qiaojiafei/platform-qa.git']]] sh 'mvn clean test -DapiTest.xml -Dmaven.test.failure.ignore=true' } stage('rd code') { echo 'This is a test step' checkout poll: false, scm: [$class: 'GitSCM', branches: [[name: '*/master']], doGenerateSubmoduleConfigurations: false, extensions: [], submoduleCfg: [], userRemoteConfigs: [[credentialsId: 'bad9f924--4416-9f5e-', url: 'http://:8000/qingzhuhotel/qingzhutool.git']]] sh 'mvn compile' } stage('DumpFromServer'){ echo 'This is a DumpFromServer step' sh label: '', script: 'mvn org.jacoco:jacoco-maven-plugin:0.8.3:dump -Djacoco.address=192.168.162.224 -Djacoco.port=6300' } stage('jacoco'){ jacoco() } }
結果展現git
jacoco原理api
官網介紹:tomcat
https://www.jacoco.org/jacoco/trunk/doc/implementation.html服務器
參考:maven