You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

GitLab流水线JUnit测试中图片附件无法显示的问题咨询

GitLab JUnit测试截图无法显示问题排查

问题描述

按GitLab官方文档配置JUnit测试报告以实现截图显示,流水线执行成功后测试列表中未出现图片,怀疑XML附件语法有误,询问当前写法是否正确。

流水线Job配置

GitlabJob:
  extends: .SomeGitLabJob

  variables:
    SomeVariable: "SomeVariable"
  artifacts:
    when: on_success
    paths:
      - my/file/location/*.png

    reports: 
      junit: my/other/location/TestRun.xml

JUnit XML文件内容

<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
<testsuites>
  <testsuite errors="0" failures="0" name="Test" skipped="0" tests="1" time="10.5401">
    <testcase classname="Test" name="Test" time="10.5401">
    <system-out>
    [[ATTACHMENT|my/file/location/picture.png]]
    </system-out>
    </testcase>
  </testsuite>
</testsuites>

解答

你当前的XML附件语法是正确的,图片不显示的问题大概率来自其他配置环节,建议从以下方向排查:

  • 验证my/file/location/picture.png文件是否在Job执行后正确生成,路径需与artifacts.paths配置完全一致(注意大小写、相对路径基准为Job工作目录)
  • 检查Job的Artifacts是否上传成功:在流水线Job详情的「Artifacts」标签下确认能看到目标png文件
  • 确保XML中的路径为相对路径,不要使用绝对路径
  • 尝试将[[ATTACHMENT|my/file/location/picture.png]]移至<system-err>标签内,部分场景下该标签的解析优先级更高
  • 确认GitLab版本在13.0及以上,该截图显示特性仅在13.0+版本中支持

内容的提问来源于stack exchange,提问作者Andy

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.19 17:40:03