Can a Test section re-use a build container

I guess I’m going wrong somewhere along the line, but I can’t seem to figure out doing tests without the test stages also having to build my projects.

I’m using the docker executor on a server install of Gitlab.

Is there a way I can have build and test stages where the test stage uses the container from the build stage? Otherwise for every build and test pipeline I have to rebuild the project just for the test stage.

I can’t see how to arrange things so the project is only built once, unless I glob testing in with the build stage and that seems to defeat the purpose of having different stages.

You can carry-forward your build result directories into test. See this previous post for more: Gitlab CI Test stage after build without rebuilding project

Thanks @hchouraria - that was the clue I needed. I had been using the needs option to control the dependencies, but now I’m using the dependencies option everything is moving across correctly and I can install the RPM from the build stage at the start of the test stage. Perfect. Thanks.