Jenkins pipeline Workspace got deleted automatically

Viewed 157

We have observed that the Jenkins Pipeline Workspace project folder getting deleted. We have not configured any cleanup plugin for this as well as not configured any cleanup module in the pipeline. This behavior is random and it's deleting Old as well as new jobs. We can see the workspace deletion traces in /var/lib/jenkins/logs/tasks under Workspace clean-up.log. Please let me know if anybody is facing the same issue and how to fix this issue? Our Jenkins version is 2.289.2

1 Answers

Try disabling the workspace cleanup. There are two ways to achieve this. I was facing the same issue and I've just tried the first approach and monitoring the workspaces to see if this works.

  1. Add -Dhudson.model.WorkspaceCleanupThread.disabled=true to the Jenkins system properties.
    • If Jenkins is running through terminal:
      • java -Dhudson.model.WorkspaceCleanupThread.disabled=true -jar jenkins.war
    • If Jenkins is running as a Linux service:
      • Stop Jenkins (service jenkins stop). You will need root privileges.
      • Edit the /etc/defaults/jenkins file.
        Add an additional line for the JAVA_ARGS or add to it if it already exists.
        JAVA_ARGS="-Dhudson.model.WorkspaceCleanupThread.disabled=true"
      • Start Jenkins (service jenkins start).
  2. Disable or uninstall the Workspace Cleanup plugin. (I haven't tried this)
Related