Can I attach images to successful pipeline jobs?

I am aware that we can attach screenshots to failed job by adding a line with [[ATTACHMENT|path/to/screenshot.png]] to the Junit XML file. I have got this to work by forcing the test to fail, but I want it to show up when the test succeeds. (I note that the test report in Gitlab just shows a link to the file, not the actual image, which I’d prefer, but that’s not my main question.)

I have code that is supposed to output a bitmap images that then needs to be checked by a human. Ideally, I would like a merge request reviewer to go to the pipeline and open the report for the relevant test to check the image looks as expected. I can do this by saving it as an artefact, but that involves additional clicking through to the artifacts area, and then through all the directories to the test output directories. If I could include it as an attachment to the test report, that would make it easier for the tester.

  • For a test report in Gitlab, based on a JUnit XML report:
    • Is it possible to show an image attached to a JUnit report for a test that succeeds?
    • Is it possible to show the actual image rather than a link?

I am using a private installation of Gitlab managed by my University.
I am using pytest to generate the JUnit report.
The pytest code for the test is as follows:

    def test_snapshot(self):
        snapshot_path = Path('output/snapshot.png').resolve()
        assert snapshot_path.is_file()

The YAML for this part of the pipeline is as follows:

  stage: test
  image: my/image:version
# other script lines
    - pytest -v --junitxml=output_report.xml -o junit_logging=all
    when: always
        - long/path/to/the/relevant/project/directory/tests/output_report.xml
      - long/path/to/the/relevant/project/directory/tests/output/snapshot.png
    expose_as: 'test-output-artifacts'
    - docker