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"
docker

      

 生成报表

           

 展示报表

      <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
View Code
#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/
合并代码覆盖率

      

搭建完毕

 

posted @ 2024-01-12 16:17  不懂123  阅读(55)  评论(0编辑  收藏  举报