1
votes

Can I have multiple Delete workspace when build is done executions in a single job?

  • failure status: clear all workspace
  • success status: clear only distribution package directories (**/target/dist)

We break our builds into compilation and test jobs with build-stalker plugin providing the link between the two. Compilation job doesn't clean up after itself as test job will do so but we don't run a test job for each compilation job (only the latest in a 4 hour period) leaving orphaned workspaces.

I'd like a way to have the orphaned workspaces have less impact and a selective status based cleanup is one way to do this.

1

1 Answers

0
votes

I'm not aware of a Jenkins plugin that supplies such a feature.

I'd establish the following:

  • Let each compile build write a line with its workspace path, e.g.:

    .../jenkins/workspace/<...compile job...>/

    by using a script in a language of your choice (bash, Groovy, cmd, ...) to a file like:

    .../jenkins/workspace/toBeWipedOut

  • Create a job that runs a script in a language of your choice periodically that:

    • reads the file
    • deletes the workspaces mentioned therein except the last
    • removes all lines therein except the last

or