I manage of Jenkins. Devs write pipeliney themselves. Not all pipelines have a workspace cleaning step.
Is it possible to inject a step into each job/build that would clear the workspace at the end of the build?
Almost all jobs are pipelines. There are a few or more freestyle projects.
I have a cronjob for this but it’s not a good solution.
I think it is possible to inject a workspace cleaning step into each job/build in Jenkins without modifying the actual pipeline scripts or job configurations. One way to achieve this would be by using the “Job DSL” plugin in Jenkins.
The “Job DSL” plugin allows you to define jobs as code using a Groovy-based domain-specific language (DSL). With this plugin, you can programmatically add a post-build step to all pipeline jobs to clean up the workspace after each build.
I’ve already thought about it, about DSL. The main problem is, it is already running Jenkins. The pipelines are modified by developers, testers etc. We/they use pipelines and freestyle jobs.
I’m thinking about rewriting tasks, but it may not be a feasible task.
Maybe I can join the DSL with other types of work?