Review Pages and artifacts: mixed versions

We use the Gitlab CI pipeline with stages “build” and “review”.
The “review” stage uses “GIT_STRATEGY: none” and gets all content from artifacts (from the “build” stage).
But because we don’t start with an clean empty directory, the current artifacts are mixed with code of older builds (older artifacts).

So we get an mix of different versions (in case of new or deleted files) which breaks our software.

For example in the “vendors” directory of our software the files are mixed together, so I don’t have the chance to only rely on files brought into the project workspace from cache or artifacts.

I’ve tried to use a before_script to clean the directory, but it’s called after downloading the artifacts. So it’s too late to delete the current directory.

We think something like “GIT_STRATEGY: empty” would be nice to start with an empty directory. So we really have only the content of the current artifacts into the directory.

Or is there an other possibility to clean the directory before unpacking the artifacts?

Thanks for your help!

@gucky; First thing I would like to say is use a docker-based CI system. That way you have clean build environments every time you run a job.

Since this is not always possible or the knowledge / learning time is not available I understand your (I assume based on your story) shell or ssh executor.

My first though towards a solution for your problem would be to introduce a stage between build and review called clean or whatever and let that stage’s job clean up your environment before your review stage / job. Since your issue is with existing files I assume the jobs are ran on the same runner / buildserver?

Yes. Every pipeline run reuses the directories of the runners. I’ve tagged the runners, so I don’t mix different parts of the projects. But the problem remains, because reusing the directory for the same part of the project makes problems too.

And there is absolutely no way to clean up such a runner directory. There are only two ways to go: Check out the repro: than I have all repro files in it - plus the artefacts from the build stage. So more files than I want - but at least only up-to-date repro files or artefacts files (that’s my workaround for the moment). The other way is to use GIT_STRATEGY none - than I have only the artefacts files. But the mixture of all artefacts files for all pipeline runs of the history for this runner.

The content of the runner directory than will by “rsynced” to a deploy directory like in any examples for gitlab-ci review setups.

I would need a way to really clean the runner directory first. Something like https://gitlab.com/gitlab-org/gitlab-ce/issues/27587