Delete build directories

ci
#1

Hi,

how can I configure my gitlab-runner to delete the build directory?
After an successful / unsucessful run there a folders with files from my project.
I want to make sure that there no old files available

0 Likes

#2

Depends on what way you are running the jobs. If you are using Docker, it will run every build in a new container, so it will be isolated by default.

0 Likes

#3

A partial solution would be to do ‘rm -rf *’ in the after_script block of your job. Haven’t done it myself; the runner cleans the folder the next time it’s used (might be the initial git checkout/clone step that does it).

0 Likes

#4

You can set some kind of expiry date after which the files will be auto deleted.

0 Likes