12

After running mvn jacoco:report how can We print coverage percentage on console ?

I can see it in browser but want it to print in jenkins.

niraj.nijju
  • 616
  • 1
  • 8
  • 17

1 Answers1

12

I got it with below command:

awk -F, \
    '{ instructions += $4 + $5; covered += $5 } END \
     { print covered, "/", instructions, " instructions covered"; \
     print 100*covered/instructions, "% covered" }' \
    target/site/jacoco/jacoco.csv
Jezor
  • 3,253
  • 2
  • 19
  • 43
niraj.nijju
  • 616
  • 1
  • 8
  • 17
  • For anyone using fish terminal, I had to surround the command section in single quotes to avoid the mismatched brackets error: awk -F, '{ instructions += $4 + $5; covered += $5 } END { print covered, "/", instructions, " instructions covered"; print 100*covered/instructions, "% covered" }' target/site/jacoco/jacoco.csv – Marquee Apr 11 '19 at 17:47
  • 1
    @Marquee Same thing with `bash`, you also need quotes – Jezor Apr 12 '19 at 10:29