Reputation: 9
I am trying to store the index.html file from the JaCoCo report by converting into PDF format in the CI/CD pipeline. What is the right command to convert from HTML to PDF in GitLab?
Upvotes: 0
Views: 867
Reputation: 46
Jacoco does not support pdf natively. It does generate an html report though. So you could use a cli tool to convert html to pdf.
For example https://wkhtmltopdf.org/ or pandoc.
You would need to install it in your job/use a docker image that contains it already.
Example:
Test:
image: maven:3.8.3-jdk-11-slim
stage: test
script:
- mvn $MAVEN_CLI_OPTS clean org.jacoco:jacoco-maven-plugin:prepare-agent test
- mvn $MAVEN_CLI_OPTS jacoco:report
artifacts:
when: always
paths:
- target/site/jacoco/jacoco.xml
jacoco2pdf:
image: riftbit/goracle:alpine-19.3
stage: deploy
script:
- cd target/site/jacoco
- wkhtmltopdf index.html jacoco.pdf
artifacts:
when: always
paths:
- target/site/jacoco/jacoco.pdf
Note that the used docker image is just an example. You should not use it in production unless you verify its contents first.
Upvotes: 1