jacoco和jenkins搭建实例
添加jacoco agent
volumes: - ./flow:/config - /data/ddos2/Javacoco/lib/jacocoagent.jar:/usr/local/jacocoagent.jar:ro environment: TZ: Asia/Shanghai entrypoint: java -javaagent:/usr/local/jacocoagent.jar=includes=*,output=tcpserver,port=7300,address=0.0.0.0,append=true -jar app.jar ports: - "8087:8087" - "7300:7300"
生成报表
展示报表
<a href="flow/html-report/index.html">查看 flow 报告 <a/>
流水线实例
#flow的report html java -jar /home/admin/jacoco/jacococli.jar dump --address 192.168.19.52 --port 7300 --destfile jacoco-flow.exec java -jar /home/admin/jacoco/jacococli.jar report jacoco-flow.exec --classfiles /var/lib/jenkins/workspace/51-app-V1.5-test/ddos-flow/target/classes --sourcefiles /var/lib/jenkins/workspace/51-app-V1.5-test/ddos-flow/src/main/java --html html-report --xml report.xml --encoding=utf-8 scp -r html-report/ root@192.168.19.52:/usr/share/nginx/html/flow/ #admin的report html
#52flow的report java -jar /home/admin/jacoco/jacococli.jar dump --address 192.168.19.52 --port 7300 --destfile jacoco-flow-52.exec #53的flow的report java -jar /home/admin/jacoco/jacococli.jar dump --address 192.168.19.53 --port 7300 --destfile jacoco-flow-53.exec #合并多个主机同一代码的覆盖率 java -jar /home/admin/jacoco/jacococli.jar merge jacoco-flow-52.exec jacoco-flow-53.exec --destfile jacoco-flow.exec #生成全量覆盖率 java -jar /home/admin/jacoco/jacococli.jar report jacoco-flow.exec --classfiles /var/lib/jenkins/workspace/51-app-V1.5-test/ddos-flow/target/classes --sourcefiles /var/lib/jenkins/workspace/51-app-V1.5-test/ddos-flow/src/main/java --html html-report --xml report.xml --encoding=utf-8 scp -r html-report/ root@192.168.19.52:/usr/share/nginx/html/flow/
搭建完毕
本文来自博客园,作者:不懂123,转载请注明原文链接:https://www.cnblogs.com/yxh168/p/17961009