【问题标题】:How do I convert JaCoCo report HTML to PDF in Maven GitLab CI/CD pipeline如何在 Maven GitLab CI/CD 管道中将 JaCoCo 报告 HTML 转换为 PDF
【发布时间】:2021-12-23 16:39:33
【问题描述】:

我正在尝试通过在 CI/CD 管道中转换为 PDF 格式来存储 JaCoCo 报告中的 index.html 文件。在 GitLab 中从 HTML 转换为 PDF 的正确命令是什么?

【问题讨论】:

    标签: java maven gitlab gitlab-ci


    【解决方案1】:

    Jacoco 本身不支持 pdf。 它确实会生成一个 html 报告。 因此,您可以使用 cli 工具将 html 转换为 pdf。

    例如https://wkhtmltopdf.org/ 或 pandoc。

    你需要在你的工作中安装它/使用一个已经包含它的 docker 镜像。

    例子:

    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
    

    请注意,使用的 docker 映像只是一个示例。除非您先验证其内容,否则不应在生产中使用它。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2022-01-09
      • 2020-02-04
      • 2021-11-28
      • 2021-12-21
      • 2021-11-30
      • 2021-04-17
      • 1970-01-01
      • 2021-04-17
      相关资源
      最近更新 更多