When running Jenkins pipeline, some repositories are checked out on the master into the workspace folder, namely the project containing the Jenkinsfile, and also the repository for the shared library. They are stored in folders named after the project, but with suffix @script resp. @libs.
Once this is done, the Jenkinsfile gets interpreted and does all its work on agents (including cloning more repos etc.).
While it is easy to clean-up on the agent at the end of the build, this does not remove the files from the master. This way, we have assembled hundreds of GB of data over time.
This clean-up can't probably be done as part of the Jenkins build (configured in Jenkinsfile), because deleteDir() can only delete from the workspace on the agent. Maybe it would work by using java.util.File methods in script block (the Groovy code is executed on master), but still the Jenkinsfile and pipeline library might be locked as long as the build is running.
So I wonder if there is any other way how to do the master clean-up. Any plugin or script? Any other idea?