Using different Docker images during a single Gitlab-CI job

I’m facing a probably classical problem, but I don’t know how to deal with, mostly due to the reset during job switching.

In my pipeline, I wish to run instrumented test and collect these data to display them on a dashboard (let’s call it SonarQube :wink: ) In order to do this, I would appreciate to use (at least) two distinct Docker environments:

  • one with the build requirements (dependencies, compilers, etc.)
  • one with the collector

I wish to use two container images because there are really distinct in term of dependencies.

Of course, the collector has to work on specific files generated by the execution of tests. If I run each step in different stages, I will lost these files.

Is there a way to describe a job using different images for specific steps?
Or is there any way to tight two jobs/stages ensuring the second jobs inherit a non-cleaned workspace?

For example, something like (pictures/examples worth thousands of words):

  - image: instrumented-build-env
    - make
    - make test
  - image: collector
    - collect