Bamboo Data Center build plan hungs while removing working directory

Still need help?

The Atlassian Community is here for you.

Ask the community

Platform Notice: Data Center - This article applies to Atlassian products on the Data Center platform.

Note that this KB was created for the Data Center version of the product. Data Center KBs for non-Data Center-specific features may also work for Server versions of the product, however they have not been tested. Support for Server* products ended on February 15th 2024. If you are running a Server product, you can visit the Atlassian Server end of support announcement to review your migration options.

*Except Fisheye and Crucible

Summary

In the Bamboo application, you can utilize the Bamboo Job's "Clean Working Directory" or the "Clean Working Directory" Task to clear the working directory either before or after the build process. However, there are instances where builds may hang during this cleaning process due to certain issues, which are discussed further in this article.

Environment

The issue was seen on Bamboo 9.5.4 running on Windows OS but the solution can be applicable for any other supported version as well.

Diagnosis

The "Could not remove working directory for plan " and "The process cannot access the file because it is being used by another process" error messages can be seen in build logs.

INFO   | jvm 1    | 2024/10/05 09:32:28 | 2024-10-05 09:32:28,042 ERROR [0-BAM::agent1.host::Agent:pool-3-thread-1] [ExecuteBuildTask] Could not remove working directory for plan 'XXX-XXX-JOB1': C:\bamboo-remote-agent-3\xml-data\build-dir\XX-XXXX-JOB1\Salesforce: The process cannot access the file because it is being used by another process.
INFO   | jvm 1    | 2024/10/05 09:32:28 | 
INFO   | jvm 1    | 2024/10/05 09:32:28 | java.nio.file.FileSystemException: C:\bamboo-remote-agent-3\xml-data\build-dir\XX-XXX-JOB1\Salesforce: The process cannot access the file because it is being used by another process.
INFO   | jvm 1    | 2024/10/05 09:32:28 | 
INFO   | jvm 1    | 2024/10/05 09:32:28 | 	at sun.nio.fs.WindowsException.translateToIOException(Unknown Source)
INFO   | jvm 1    | 2024/10/05 09:32:28 | 	at sun.nio.fs.WindowsException.rethrowAsIOException(Unknown Source)
INFO   | jvm 1    | 2024/10/05 09:32:28 | 	at sun.nio.fs.WindowsException.rethrowAsIOException(Unknown Source)
INFO   | jvm 1    | 2024/10/05 09:32:28 | 	at sun.nio.fs.WindowsFileSystemProvider.implDelete(Unknown Source)
INFO   | jvm 1    | 2024/10/05 09:32:28 | 	at sun.nio.fs.AbstractFileSystemProvider.delete(Unknown Source)
INFO   | jvm 1    | 2024/10/05 09:32:28 | 	at java.nio.file.Files.delete(Unknown Source) 

Please check the Windows process monitor to see whether any child process still running from the Build Job. We have seen  similar issues when user uses Salesforce cli telemetry.

Cause

When you use script tasks which calls other process inside the agent environment it may spawn other child process which may not release the Bamboo jobs working directory completely even though the script task has been completed. In such situations it can interrupt the 'Clean Working Directory' process in Bamboo which results the build to hung.

Solution

Bamboo has no way of detecting whether the spawned process is not intentional within its design. So, please check the process monitors and check for running process that may stop Bamboo from cleaning the working directory.You can use the  Process monitor (https://learn.microsoft.com/en-us/sysinternals/downloads/procmon) monitor such processes. 



Last modified on Nov 29, 2024

Was this helpful?

Yes
No
Provide feedback about this article
Powered by Confluence and Scroll Viewport.