Builds failing with "The process cannot access the file because it is being used by another process"

お困りですか?

アトラシアン コミュニティをご利用ください。

コミュニティに質問

プラットフォームについて: Server および Data Center のみ。この記事は、Server および Data Center プラットフォームのアトラシアン製品にのみ適用されます。

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.

*Fisheye および Crucible は除く

要約

Builds fail during the Source Code Checkout task, and the agent's logs show the following error:

java.lang.RuntimeException: java.io.FileNotFoundException: C:\Windows\TEMP\bamboo-ssh.41538fd5.bat (The process cannot access the file because it is being used by another process)

原因

The "The process cannot access the file because it is being used by another process" error indicates that there is another process, external to the Bamboo Agent's one, that's trying to access the same file at the same time.

This could happen for many reasons, but the most common cause is that there are two builds running concurrently, checking out the same repository. This wouldn't be a problem, but it becomes one when the two agents are running on the same machine and share the same temporary directory. You can check if that's the case by referring to the agent's logs during a startup timeframe:

<AGENT_ONE_HOME>/logs/atlassian-bamboo.log
2021-10-22 15:36:05,129 INFO [AgentRunnerThread] [lifecycle] *******************************
2021-10-22 15:36:05,129 INFO [AgentRunnerThread] [lifecycle] *      System information     *
2021-10-22 15:36:05,129 INFO [AgentRunnerThread] [lifecycle] *******************************
2021-10-22 15:36:05,192 INFO [AgentRunnerThread] [lifecycle] com.atlassian.bamboo.configuration.SystemInfoImpl@1cf7d169[
...
  localHomeDirectory=c:\Bamboo_Agent_One
...
  tempDir=C:\Windows\TEMP\
...
<AGENT_TWO_HOME>/logs/atlassian-bamboo.log
2021-10-23 11:26:03,121 INFO [AgentRunnerThread] [lifecycle] *******************************
2021-10-23 11:26:03,121 INFO [AgentRunnerThread] [lifecycle] *      System information     *
2021-10-23 11:26:03,121 INFO [AgentRunnerThread] [lifecycle] *******************************
2021-10-23 11:26:03,188 INFO [AgentRunnerThread] [lifecycle] com.atlassian.bamboo.configuration.SystemInfoImpl@1cf7d169[
...
  localHomeDirectory=c:\Bamboo_Agent_Two
...
  tempDir=C:\Windows\TEMP\
...

Comparing the two agents' logs, we can see that, even though each one has their own dedicated Home Directory, they still do share the same Temporary Directory, as per the tempDir property value.

ソリューション

Upon identifying that the above is the cause on your environment, the best approach would be to set each agent on the server to use a different temporary directory. If agents running on the same server have different temporary directories, the "The process cannot access the file because it is being used by another process" error should no longer occur.

Please see the following article for steps on how to change the agents' temporary directories:


最終更新日: 2021 年 10 月 28 日

この内容はお役に立ちましたか?

はい
いいえ
この記事についてのフィードバックを送信する
Powered by Confluence and Scroll Viewport.