Workspace deleted on build node when Jenkins controller restarted

I am executing a pipeline job on a build node and observed that the workspace is getting deleted from the build node whenever the Jenkins controller restarts. I have observed this consistently for multiple times.
I could not find if it is expected behavior of Jenkins or not from the documentation.

Can anyone let me know how can I preserve the workspace when the controller restarts while job is in progress?

Hello @chakravarthy392 and welcome to this community :wave:

What is the list of installed plugins on your controller? You could have one plugins that does it for you without you knowing.
To get the list, you can go to http://<yourcontroller>/script and enter this script in the textbox and then click Run.

Jenkins.instance.pluginManager.plugins.each{
  plugin -> 
    println ("${plugin.getDisplayName()} (${plugin.getShortName()}): ${plugin.getVersion()}")
}

Hi @poddingue ,
Seems too many plugins are installed.

Result: [Plugin:blueocean-commons, Plugin:structs, Plugin:junit, Plugin:workflow-cps-global-lib, Plugin:workflow-step-api, Plugin:workflow-scm-step, Plugin:credentials, Plugin:branch-api, Plugin:ssh-credentials, Plugin:variant, Plugin:git-client, Plugin:scm-api, Plugin:display-url-api, Plugin:jackson2-api, Plugin:mailer, Plugin:workflow-multibranch, Plugin:script-security, Plugin:matrix-project, Plugin:git, Plugin:mercurial, Plugin:metrics, Plugin:ace-editor, Plugin:docker-commons, Plugin:jquery-detached, Plugin:workflow-api, Plugin:workflow-support, Plugin:blueocean-web, Plugin:workflow-cps, Plugin:blueocean-rest, Plugin:workflow-job, Plugin:multiple-scms, Plugin:bitbucket, Plugin:bitbucket-build-status-notifier, Plugin:durable-task, Plugin:authentication-tokens, Plugin:ant, Plugin:windows-slaves, Plugin:icon-shim, Plugin:blueocean-jwt, Plugin:matrix-auth, Plugin:pipeline-stage-step, Plugin:antisamy-markup-formatter, Plugin:token-macro, Plugin:docker-workflow, Plugin:plain-credentials, Plugin:favorite, Plugin:stashNotifier, Plugin:github-api, Plugin:github, Plugin:github-branch-source, Plugin:pipeline-input-step, Plugin:git-server, Plugin:pipeline-graph-analysis, Plugin:workflow-basic-steps, Plugin:credentials-binding, Plugin:pipeline-model-definition, Plugin:pipeline-model-api, Plugin:pipeline-model-extensions, Plugin:cloudbees-folder, Plugin:resource-disposer, Plugin:workflow-durable-task-step, Plugin:nodejs, Plugin:pipeline-stage-tags-metadata, Plugin:pipeline-model-declarative-agent, Plugin:blueocean-rest-impl, Plugin:ws-cleanup, Plugin:blueocean-pipeline-api-impl, Plugin:email-ext, Plugin:mapdb-api, Plugin:ssh-slaves, Plugin:blueocean-git-pipeline, Plugin:blueocean-config, Plugin:sse-gateway, Plugin:bouncycastle-api, Plugin:blueocean-events, Plugin:extended-choice-parameter, Plugin:blueocean-personalization, Plugin:blueocean-display-url, Plugin:configurationslicing, Plugin:blueocean-pipeline-editor, Plugin:custom-tools-plugin, Plugin:blueocean-autofavorite, Plugin:pubsub-light, Plugin:blueocean-i18n, Plugin:skip-certificate-check, Plugin:blueocean-dashboard, Plugin:StashBranchParameter, Plugin:cloudbees-bitbucket-branch-source, Plugin:bitbucket-pullrequest-builder, Plugin:subversion, Plugin:pam-auth, Plugin:ldap, Plugin:external-monitor-job, Plugin:cvs, Plugin:greenballs, Plugin:JDK_Parameter_Plugin, Plugin:javadoc, Plugin:jquery, Plugin:pipeline-milestone-step, Plugin:pipeline-rest-api, Plugin:handlebars, Plugin:momentjs, Plugin:publish-to-bitbucket, Plugin:pipeline-build-step, Plugin:workflow-aggregator, Plugin:config-file-provider, Plugin:maven-plugin, Plugin:m2release, Plugin:rundeck, Plugin:release, Plugin:command-launcher, Plugin:apache-httpcomponents-client-4-api, Plugin:pipeline-utility-steps, Plugin:blueocean-pipeline-scm-api, Plugin:stash-pullrequest-builder, Plugin:blueocean-github-pipeline, Plugin:git-changelog, Plugin:jdk-tool, Plugin:blueocean-core-js, Plugin:blueocean-jira, Plugin:pipeline-stage-view, Plugin:discard-old-build, Plugin:permissive-script-security, Plugin:jira, Plugin:htmlpublisher, Plugin:jsch, Plugin:gradle, Plugin:blueocean, Plugin:cloudbees-disk-usage-simple, Plugin:pipeline-multibranch-defaults, Plugin:nexus-artifact-uploader, Plugin:build-user-vars-plugin, Plugin:sonar, Plugin:scm-filter-branch-pr, Plugin:slack, Plugin:hudson-wsclean-plugin, Plugin:modernstatus, Plugin:saferestart, Plugin:blueocean-bitbucket-pipeline, Plugin:jenkins-design-language, Plugin:jquery-ui, Plugin:hashicorp-vault-plugin, Plugin:handy-uri-templates-2-api, Plugin:http_request, Plugin:allure-jenkins-plugin, Plugin:git-parameter, Plugin:run-condition, Plugin:serenity, Plugin:conditional-buildstep, Plugin:parameterized-trigger, Plugin:purge-build-queue-plugin, Plugin:ansible, Plugin:Parameterized-Remote-Trigger, Plugin:ignore-committer-strategy, Plugin:blueocean-executor-info, Plugin:uno-choice, Plugin:lockable-resources, Plugin:ansible-tower, Plugin:jobConfigHistory, Plugin:plugin-util-api, Plugin:extensible-choice-parameter, Plugin:mask-passwords, Plugin:ssh-agent, Plugin:leastload, Plugin:trilead-api, Plugin:dynamic_extended_choice_parameter, Plugin:role-strategy, Plugin:parameterized-scheduler, Plugin:caffeine-api, Plugin:hashicorp-vault-pipeline, Plugin:echarts-api, Plugin:emailext-template, Plugin:sshd, Plugin:extended-read-permission, Plugin:pipeline-groovy-lib, Plugin:jmh-report, Plugin:okhttp-api, Plugin:javax-mail-api, Plugin:next-build-number, Plugin:font-awesome-api, Plugin:popper2-api, Plugin:jjwt-api, Plugin:build-name-setter, Plugin:rebuild, Plugin:veracode-scan, Plugin:javax-activation-api, Plugin:thinBackup, Plugin:popper-api, Plugin:jquery3-api, Plugin:bootstrap4-api, Plugin:openshift-client, Plugin:jaxb, Plugin:checks-api, Plugin:performance, Plugin:ansicolor, Plugin:bootstrap5-api, Plugin:scm2job, Plugin:azure-commons, Plugin:snakeyaml-api, Plugin:global-build-stats, Plugin:chromedriver, Plugin:openJDK-native-plugin, Plugin:saml, Plugin:adoptopenjdk, Plugin:azure-sdk, Plugin:azure-credentials, Plugin:notification, Plugin:jakarta-activation-api, Plugin:jakarta-mail-api]

1 Like

I can see a few plugins that could take care of removing resources without asking…

I guess the ws-cleanup plugin gives options to clean up the workspace before starting the job/ after completing the job but it should not delete the workspace when Jenkins restarts. Anyway, I will check the documentation of those plugins just to be sure.

1 Like

Well, it is not expected behavior and I still see this issue with few my jobs. Unfortunately, we can not exactly replicate the same job on test environment.

I have the same problem with two builds that last for 3 or 4 hours to build and it is rather annoying that the build output disappears every once and while.
So I can confirm the problem still exists. My list of plugins is the following:

Result: [Plugin:Office-365-Connector, Plugin:active-directory, Plugin:all-changes, Plugin:analysis-model-api, Plugin:android-signing, Plugin:ansicolor, Plugin:ant, Plugin:antisamy-markup-formatter, Plugin:apache-httpcomponents-client-4-api, Plugin:apache-httpcomponents-client-5-api, Plugin:authentication-tokens, Plugin:blueocean-autofavorite, Plugin:blueocean-bitbucket-pipeline, Plugin:blueocean-commons, Plugin:blueocean-config, Plugin:blueocean-core-js, Plugin:blueocean-dashboard, Plugin:blueocean-display-url, Plugin:blueocean-events, Plugin:blueocean-git-pipeline, Plugin:blueocean-github-pipeline, Plugin:blueocean-i18n, Plugin:blueocean-jira, Plugin:blueocean-jwt, Plugin:blueocean-personalization, Plugin:blueocean-pipeline-api-impl, Plugin:blueocean-pipeline-editor, Plugin:blueocean-pipeline-scm-api, Plugin:blueocean-rest-impl, Plugin:blueocean-rest, Plugin:blueocean-web, Plugin:blueocean, Plugin:bootstrap5-api, Plugin:bouncycastle-api, Plugin:branch-api, Plugin:build-timeout, Plugin:built-on-column, Plugin:caffeine-api, Plugin:checks-api, Plugin:chucknorris, Plugin:cloud-stats, Plugin:cloudbees-bitbucket-branch-source, Plugin:cloudbees-folder, Plugin:cobertura, Plugin:code-coverage-api, Plugin:command-launcher, Plugin:commons-httpclient3-api, Plugin:commons-lang3-api, Plugin:commons-text-api, Plugin:conditional-buildstep, Plugin:configurationslicing, Plugin:copyartifact, Plugin:coverage, Plugin:credentials-binding, Plugin:credentials, Plugin:custom-view-tabs, Plugin:cvs, Plugin:dashboard-view, Plugin:data-tables-api, Plugin:dependency-check-jenkins-plugin, Plugin:dependency-track, Plugin:depgraph-view, Plugin:display-url-api, Plugin:docker-commons, Plugin:docker-java-api, Plugin:docker-plugin, Plugin:docker-workflow, Plugin:doclinks, Plugin:doxygen, Plugin:dtkit-api, Plugin:durable-task, Plugin:echarts-api, Plugin:email-ext, Plugin:envinject-api, Plugin:envinject, Plugin:extended-read-permission, Plugin:external-monitor-job, Plugin:favorite, Plugin:file-operations, Plugin:font-awesome-api, Plugin:forensics-api, Plugin:git-client, Plugin:git-server, Plugin:git, Plugin:gitea, Plugin:github-api, Plugin:github-branch-source, Plugin:github, Plugin:gitlab-api, Plugin:gitlab-branch-source, Plugin:gitlab-plugin, Plugin:gradle, Plugin:handy-uri-templates-2-api, Plugin:htmlpublisher, Plugin:instance-identity, Plugin:ionicons-api, Plugin:jackson2-api, Plugin:jakarta-activation-api, Plugin:jakarta-mail-api, Plugin:javadoc, Plugin:javax-activation-api, Plugin:javax-mail-api, Plugin:jaxb, Plugin:jdk-tool, Plugin:jenkins-design-language, Plugin:jersey2-api, Plugin:jira, Plugin:jjwt-api, Plugin:jobConfigHistory, Plugin:join, Plugin:jquery, Plugin:jquery3-api, Plugin:jsch, Plugin:junit, Plugin:last-changes, Plugin:ldap, Plugin:locale, Plugin:lockable-resources, Plugin:mail-watcher-plugin, Plugin:mailer, Plugin:mapdb-api, Plugin:matrix-auth, Plugin:matrix-project, Plugin:maven-plugin, Plugin:metrics, Plugin:mina-sshd-api-common, Plugin:mina-sshd-api-core, Plugin:msbuild, Plugin:mstest, Plugin:mstestrunner, Plugin:nested-view, Plugin:nexus-artifact-uploader, Plugin:nexus-jenkins-plugin, Plugin:nunit, Plugin:okhttp-api, Plugin:pam-auth, Plugin:parameterized-trigger, Plugin:patch-parameter, Plugin:pipeline-aggregator-view, Plugin:pipeline-build-step, Plugin:pipeline-github-lib, Plugin:pipeline-graph-analysis, Plugin:pipeline-graph-view, Plugin:pipeline-groovy-lib, Plugin:pipeline-input-step, Plugin:pipeline-milestone-step, Plugin:pipeline-model-api, Plugin:pipeline-model-definition, Plugin:pipeline-model-extensions, Plugin:pipeline-rest-api, Plugin:pipeline-stage-step, Plugin:pipeline-stage-tags-metadata, Plugin:pipeline-stage-view, Plugin:plain-credentials, Plugin:plugin-usage-plugin, Plugin:plugin-util-api, Plugin:powershell, Plugin:prism-api, Plugin:pubsub-light, Plugin:resource-disposer, Plugin:role-strategy, Plugin:run-condition, Plugin:scm-api, Plugin:script-security, Plugin:snakeyaml-api, Plugin:sonar, Plugin:sse-gateway, Plugin:ssh-credentials, Plugin:ssh-slaves, Plugin:sshd, Plugin:structs, Plugin:subversion, Plugin:timestamper, Plugin:token-macro, Plugin:trilead-api, Plugin:variant, Plugin:versioncolumn, Plugin:versionnumber, Plugin:warnings-ng, Plugin:windows-slaves, Plugin:workflow-aggregator, Plugin:workflow-api, Plugin:workflow-basic-steps, Plugin:workflow-cps, Plugin:workflow-durable-task-step, Plugin:workflow-job, Plugin:workflow-multibranch, Plugin:workflow-scm-step, Plugin:workflow-step-api, Plugin:workflow-support, Plugin:ws-cleanup, Plugin:xunit]