Cicd cleanup before git checkout

My ci jobs leave unwanted files that cause a later git checkout in the same runner to fail.
Trying to remove those files in the before_script is not helping, because before_script is executing after git checkout.

Is it possible to run a command before the git checkout?
Alternatively, how do I cleanup after a job is executed, regardless of its success or failure?

right now I have to manually go into the runner file system and remove leftover files.

On runner side you can use the commands pre_clone_script for executing scripts before cloning.
Cleanup jobs I usually run in my CI Jobs with after_script.

Hope those 2 options might help you.

Thank you.
pre_clone_script is exactly what I needed.

I too use an after-script cleanup, but, for reasons I do not understand, it sometimes leaves garbage behind.

1 Like