Bamboo: Deployment fails with "Unable to clean working directory"
Asked by Dennis Grassmann:

Hello all,  

Since the day we have updated to version 6.5.1, several deployments fail at the "Clean working directory task". As workaround we just rerun the same deployment. It always works on the second attempt, but it is getting really annoying.  

Here is the original exception:  
{noformat}  
3-Sep-2018 10:14:48 Starting task 'Cleanup' of type 'com.atlassian.bamboo.plugins.bamboo-artifact-downloader-plugin:cleanWorkingDirectoryTask'  
03-Sep-2018 10:14:48 Cleaning working directory '/opt/ac/acsd/bamboo-agent-home/xml-data/build-dir/5898243-5963779'  
03-Sep-2018 10:14:48 Unable to clean working directory '/opt/ac/acsd/bamboo-agent-home/xml-data/build-dir/5898243-5963779' /opt/ac/acsd/bamboo-agent-home/xml-data/build-dir/5898243-5963779  
03-Sep-2018 10:14:48 Error occurred while running Task 'Cleanup(6)' of type com.atlassian.bamboo.plugins.bamboo-artifact-downloader-plugin:cleanWorkingDirectoryTask.  
03-Sep-2018 10:14:48 com.atlassian.bamboo.task.TaskException: Unable to clean working directory '/opt/ac/acsd/bamboo-agent-home/xml-data/build-dir/5898243-5963779' /opt/ac/acsd/bamboo-agent-home/xml-data/build-dir/5898243-5963779  
03-Sep-2018 10:14:48 at com.atlassian.bamboo.plugins.artifact.CleanWorkingDirectoryTask.cleanWorkingDir(CleanWorkingDirectoryTask.java:52)  
03-Sep-2018 10:14:48 at com.atlassian.bamboo.plugins.artifact.CleanWorkingDirectoryTask.execute(CleanWorkingDirectoryTask.java:26)  
03-Sep-2018 10:14:48 at com.atlassian.bamboo.task.TaskExecutorImpl.lambda$executeTasks$3(TaskExecutorImpl.java:285)  
03-Sep-2018 10:14:48 at com.atlassian.bamboo.task.TaskExecutorImpl.executeTaskWithPrePostActions(TaskExecutorImpl.java:224)  
03-Sep-2018 10:14:48 at com.atlassian.bamboo.task.TaskExecutorImpl.executeTasks(TaskExecutorImpl.java:285)  
03-Sep-2018 10:14:48 at com.atlassian.bamboo.task.TaskExecutorImpl.execute(TaskExecutorImpl.java:112)  
03-Sep-2018 10:14:48 at com.atlassian.bamboo.build.pipeline.tasks.ExecuteBuildTask.call(ExecuteBuildTask.java:71)  
03-Sep-2018 10:14:48 at com.atlassian.bamboo.v2.build.agent.DefaultBuildAgent.executeBuildPhase(DefaultBuildAgent.java:203)  
03-Sep-2018 10:14:48 at com.atlassian.bamboo.v2.build.agent.DefaultBuildAgent.build(DefaultBuildAgent.java:175)  
03-Sep-2018 10:14:48 at com.atlassian.bamboo.v2.build.agent.BuildAgentControllerImpl.lambda$waitAndPerformBuild$0(BuildAgentControllerImpl.java:122)  
03-Sep-2018 10:14:48 at com.atlassian.bamboo.variable.CustomVariableContextImpl.withVariableSubstitutor(CustomVariableContextImpl.java:185)  
03-Sep-2018 10:14:48 at com.atlassian.bamboo.v2.build.agent.BuildAgentControllerImpl.waitAndPerformBuild(BuildAgentControllerImpl.java:117)  
03-Sep-2018 10:14:48 at com.atlassian.bamboo.v2.build.agent.DefaultBuildAgent$1.run(DefaultBuildAgent.java:126)  
03-Sep-2018 10:14:48 at com.atlassian.bamboo.utils.BambooRunnables$1.run(BambooRunnables.java:48)  
03-Sep-2018 10:14:48 at com.atlassian.bamboo.security.ImpersonationHelper.runWith(ImpersonationHelper.java:26)  
03-Sep-2018 10:14:48 at com.atlassian.bamboo.security.ImpersonationHelper.runWithSystemAuthority(ImpersonationHelper.java:17)  
03-Sep-2018 10:14:48 at com.atlassian.bamboo.security.ImpersonationHelper$1.run(ImpersonationHelper.java:41)  
03-Sep-2018 10:14:48 at java.lang.Thread.run(Thread.java:748)  
03-Sep-2018 10:14:48 Caused by: java.nio.file.NoSuchFileException: /opt/ac/acsd/bamboo-agent-home/xml-data/build-dir/5898243-5963779  
03-Sep-2018 10:14:48 at sun.nio.fs.UnixException.translateToIOException(UnixException.java:86)  
03-Sep-2018 10:14:48 at sun.nio.fs.UnixException.asIOException(UnixException.java:111)  
03-Sep-2018 10:14:48 at sun.nio.fs.UnixDirectoryStream$UnixDirectoryIterator.readNextEntry(UnixDirectoryStream.java:171)  
03-Sep-2018 10:14:48 at sun.nio.fs.UnixDirectoryStream$UnixDirectoryIterator.hasNext(UnixDirectoryStream.java:201)  
03-Sep-2018 10:14:48 at java.nio.file.FileTreeWalker.next(FileTreeWalker.java:348)  
03-Sep-2018 10:14:48 at java.nio.file.Files.walkFileTree(Files.java:2706)  
03-Sep-2018 10:14:48 at java.nio.file.Files.walkFileTree(Files.java:2742)  
03-Sep-2018 10:14:48 at com.atlassian.bamboo.utils.BambooPathUtils.cleanDirectory(BambooPathUtils.java:74)  
03-Sep-2018 10:14:48 at com.atlassian.bamboo.plugins.artifact.CleanWorkingDirectoryTask.cleanWorkingDir(CleanWorkingDirectoryTask.java:48)  
03-Sep-2018 10:14:48 ... 17 more  
{noformat}  

Any suggestions?  

Kind regards,  

Dennis


Answers:
author: Prashant Mali
body: Hi [@Dennis Grassmann](/t5/user/viewprofilepage/user-id/605729)

I get this problem if the source directory contains file/directory names consisting of non-UTF-8 characters. Please check format character and confirm.

Thanks,

Prashnat

comments: author: Dennis Grassmann
body: Hi [@Prashant Mali](/t5/user/viewprofilepage/user-id/286095),

I used several approaches to find any invalid names and could not even find any non-ASCII file names at all.

{code}

find . \| perl -ane '{ if(m/\[\[:\^ascii:\]\]/) { print } }'

LC_ALL=C find . -name '\*\[! -\~\]\*'

find . \| tr -d '\[\\200-\\377\]'

{code}

Any other suggestions?

Kind regards,

Dennis