Steps to reproduce
- Create a new plan that has a single task to check out a Git repository.
- In the Source Code Checkout task, tick "Force Clean Build".
- In the Miscellaneous tab of the job, tick "Clean working directory after each build".
- Start a Windows elastic Bamboo agent and run a couple of builds.
Expected results
All the builds check out the code successfully and subsequently clean up the working directory.
Actual results
The first build will pass, but an error will appear in the Bamboo error log:
Could not remove working directory for plan 'TEST-BUIL-JOB1': C:\build\TEST-BUIL-JOB1\.git
java.nio.file.DirectoryNotEmptyException: C:\build\TEST-BUIL-JOB1\.git
at sun.nio.fs.WindowsFileSystemProvider.implDelete(WindowsFileSystemProvider.java:266)
at sun.nio.fs.AbstractFileSystemProvider.delete(AbstractFileSystemProvider.java:103)
at java.nio.file.Files.delete(Files.java:1126)
at com.atlassian.bamboo.utils.BambooPathUtils.deleteNoThrow(BambooPathUtils.java:158)
at com.atlassian.bamboo.utils.BambooPathUtils.access$000(BambooPathUtils.java:28)
at com.atlassian.bamboo.utils.BambooPathUtils$1.postVisitDirectory(BambooPathUtils.java:97)
at com.atlassian.bamboo.utils.BambooPathUtils$1.postVisitDirectory(BambooPathUtils.java:74)
at java.nio.file.Files.walkFileTree(Files.java:2688)
at java.nio.file.Files.walkFileTree(Files.java:2742)
at com.atlassian.bamboo.utils.BambooPathUtils.cleanDirectory(BambooPathUtils.java:103)
at com.atlassian.bamboo.util.BambooFileUtils.cleanDirectory(BambooFileUtils.java:770)
at com.atlassian.bamboo.build.pipeline.tasks.ExecuteBuildTask.cleanWorkingDirectory(ExecuteBuildTask.java:129)
at com.atlassian.bamboo.build.pipeline.tasks.ExecuteBuildTask.call(ExecuteBuildTask.java:98)
at com.atlassian.bamboo.v2.build.agent.DefaultBuildAgent.build(DefaultBuildAgent.java:196)
at com.atlassian.bamboo.v2.build.agent.BuildAgentControllerImpl$1.call(BuildAgentControllerImpl.java:132)
at com.atlassian.bamboo.v2.build.agent.BuildAgentControllerImpl$1.call(BuildAgentControllerImpl.java:123)
at com.atlassian.bamboo.variable.CustomVariableContextImpl.withVariableSubstitutor(CustomVariableContextImpl.java:215)
at com.atlassian.bamboo.v2.build.agent.BuildAgentControllerImpl.waitAndPerformBuild(BuildAgentControllerImpl.java:122)
at com.atlassian.bamboo.v2.build.agent.DefaultBuildAgent$1.run(DefaultBuildAgent.java:118)
at com.atlassian.bamboo.utils.BambooRunnables$1.run(BambooRunnables.java:49)
at com.atlassian.bamboo.security.ImpersonationHelper.runWith(ImpersonationHelper.java:31)
at com.atlassian.bamboo.security.ImpersonationHelper.runWithSystemAuthority(ImpersonationHelper.java:20)
at com.atlassian.bamboo.security.ImpersonationHelper$1.run(ImpersonationHelper.java:52)
at java.lang.Thread.run(Thread.java:745)
Subsequent builds will all fail with the error:
Starting task 'Checkout Default Repository' of type 'com.atlassian.bamboo.plugins.vcs:task.vcs.checkout'
Build always requires a clean checkout
Cleaning build directory 'C:\build-dir\TEST-BUIL-JOB1'
Unable to clean source directory 'C:\build-dir\TEST-BUIL-JOB1' C:\build-dir\TEST-BUIL-JOB1\.git
Build always requires a clean checkout
Cleaning build directory 'C:\build-dir\TEST-BUIL-JOB1'
Unable to clean source directory 'C:\build-dir\TEST-BUIL-JOB1' C:\build-dir\TEST-BUIL-JOB1\.git
Build always requires a clean checkout
Cleaning build directory 'C:\build-dir\TEST-BUIL-JOB1'
Unable to clean source directory 'C:\build-dir\TEST-BUIL-JOB1' C:\build-dir\TEST-BUIL-JOB1\.git
Error occurred while running Task 'Checkout Default Repository(1)' of type com.atlassian.bamboo.plugins.vcs:task.vcs.checkout.
java.lang.RuntimeException: com.atlassian.bamboo.repository.RepositoryException: Unable to clean source directory 'C:\build-dir\TEST-BUIL-JOB1' C:\build-dir\TEST-BUIL-JOB1\.git
at com.atlassian.bamboo.executor.RetryingTaskExecutor.rerun(RetryingTaskExecutor.java:144)
at com.atlassian.bamboo.executor.RetryingTaskExecutor.runTask(RetryingTaskExecutor.java:88)
at com.atlassian.bamboo.executor.RetryingTaskExecutor.retry(RetryingTaskExecutor.java:203)
at com.atlassian.bamboo.executor.RetryingTaskExecutor.retry(RetryingTaskExecutor.java:188)
at com.atlassian.bamboo.plugins.vcs.task.VcsCheckoutTask.preRetrieveSourceCode(VcsCheckoutTask.java:217)
at com.atlassian.bamboo.plugins.vcs.task.VcsCheckoutTask.execute(VcsCheckoutTask.java:124)
at com.atlassian.bamboo.task.TaskExecutorImpl.lambda$executeTasks$68(TaskExecutorImpl.java:273)
at com.atlassian.bamboo.task.TaskExecutorImpl$$Lambda$20/1672639360.call(Unknown Source)
at com.atlassian.bamboo.task.TaskExecutorImpl.executeTaskWithPrePostActions(TaskExecutorImpl.java:202)
at com.atlassian.bamboo.task.TaskExecutorImpl.executeTasks(TaskExecutorImpl.java:273)
at com.atlassian.bamboo.task.TaskExecutorImpl.executePreparationTasks(TaskExecutorImpl.java:83)
at com.atlassian.bamboo.build.pipeline.tasks.PrepareBuildTask.call(PrepareBuildTask.java:74)
at com.atlassian.bamboo.v2.build.agent.DefaultBuildAgent.build(DefaultBuildAgent.java:196)
at com.atlassian.bamboo.v2.build.agent.BuildAgentControllerImpl$1.call(BuildAgentControllerImpl.java:132)
at com.atlassian.bamboo.v2.build.agent.BuildAgentControllerImpl$1.call(BuildAgentControllerImpl.java:123)
at com.atlassian.bamboo.variable.CustomVariableContextImpl.withVariableSubstitutor(CustomVariableContextImpl.java:215)
at com.atlassian.bamboo.v2.build.agent.BuildAgentControllerImpl.waitAndPerformBuild(BuildAgentControllerImpl.java:122)
at com.atlassian.bamboo.v2.build.agent.DefaultBuildAgent$1.run(DefaultBuildAgent.java:118)
at com.atlassian.bamboo.utils.BambooRunnables$1.run(BambooRunnables.java:49)
at com.atlassian.bamboo.security.ImpersonationHelper.runWith(ImpersonationHelper.java:31)
at com.atlassian.bamboo.security.ImpersonationHelper.runWithSystemAuthority(ImpersonationHelper.java:20)
at com.atlassian.bamboo.security.ImpersonationHelper$1.run(ImpersonationHelper.java:52)
at java.lang.Thread.run(Thread.java:745)
Caused by: com.atlassian.bamboo.repository.RepositoryException: Unable to clean source directory 'C:\build-dir\TEST-BUIL-JOB1' C:\build-dir\TEST-BUIL-JOB1\.git
at com.atlassian.bamboo.plugins.vcs.task.VcsCheckoutTask.cleanWorkingDirIfNeeded(VcsCheckoutTask.java:371)
at com.atlassian.bamboo.plugins.vcs.task.VcsCheckoutTask.access$100(VcsCheckoutTask.java:57)
at com.atlassian.bamboo.plugins.vcs.task.VcsCheckoutTask$2.call(VcsCheckoutTask.java:222)
at com.atlassian.bamboo.plugins.vcs.task.VcsCheckoutTask$2.call(VcsCheckoutTask.java:218)
at com.atlassian.bamboo.executor.RetryingTaskExecutor.rerun(RetryingTaskExecutor.java:108)
... 22 more
Caused by: java.nio.file.DirectoryNotEmptyException: C:\build-dir\TEST-BUIL-JOB1\.git
at sun.nio.fs.WindowsFileSystemProvider.implDelete(WindowsFileSystemProvider.java:266)
at sun.nio.fs.AbstractFileSystemProvider.delete(AbstractFileSystemProvider.java:103)
at java.nio.file.Files.delete(Files.java:1126)
at com.atlassian.bamboo.utils.BambooPathUtils.deleteNoThrow(BambooPathUtils.java:158)
at com.atlassian.bamboo.utils.BambooPathUtils.access$000(BambooPathUtils.java:28)
at com.atlassian.bamboo.utils.BambooPathUtils$1.postVisitDirectory(BambooPathUtils.java:97)
at com.atlassian.bamboo.utils.BambooPathUtils$1.postVisitDirectory(BambooPathUtils.java:74)
at java.nio.file.Files.walkFileTree(Files.java:2688)
at java.nio.file.Files.walkFileTree(Files.java:2742)
at com.atlassian.bamboo.utils.BambooPathUtils.cleanDirectory(BambooPathUtils.java:103)
at com.atlassian.bamboo.util.BambooFileUtils.cleanDirectory(BambooFileUtils.java:770)
at com.atlassian.bamboo.plugins.vcs.task.VcsCheckoutTask.cleanWorkingDirIfNeeded(VcsCheckoutTask.java:365)
error 04-Nov-2015 13:51:01 ... 26 more
Workaround
Add a script task to move (not delete) the .git directory out of the working directory.
Has this fix been included in the commercial server release version yet?