Skip to content

The process cannot access the file because it is being used by another process #125

Description

@Alinoe22

Describe the bug

When running the following command:

environment {
	JFROG_CLI_TEMP_DIR="$WORKSPACE/jfrog-temp/"
  }

jf "rt build-add-dependencies --project=proj --from-rt=true --server-id=artifactory --spec=./release-bundle.json MyBundle 58"

More often than not I have this error:

Failed to close reader: remove D:\Jenkins\workspace\MyJob/jfrog-temp/jfrog.cli.temp.-1739798442-2443638522: The process cannot access the file because it is being used by another process.

It sometimes work, which makes me think there is a race condition somewhere.

Current behavior

The jfrog plugin fails with this log:

[2025-02-17T13:20:03.914Z] [MyJob] $ D:\Jenkins\tools\io.jenkins.plugins.jfrog.JfrogInstallation\jfrog-cli\jf.exe -v
[2025-02-17T13:20:04.896Z] [MyJob] $ cmd.exe /C "D:\Jenkins\tools\io.jenkins.plugins.jfrog.JfrogInstallation\jfrog-cli\jf.exe c add artifactory --user=my_user --password-stdin --url=https://artifactory.domain.net/ --artifactory-url=https://artifactory.domain.net/artifactory --distribution-url=https://artifactory.domain.net/distribution --xray-url=https://artifactory.domain.net/xray --interactive=false --overwrite=true && exit %%ERRORLEVEL%%"

[2025-02-17T13:20:05.274Z] [MyJob] $ cmd.exe /C "D:\Jenkins\tools\io.jenkins.plugins.jfrog.JfrogInstallation\jfrog-cli\jf.exe rt build-add-dependencies --project=proj --from-rt=true --server-id=artifactory --spec=./release-bundle.json MyBundle 58 && exit %%ERRORLEVEL%%"

[2025-02-17T13:20:05.763Z] 13:20:05 [Info] Running Build Add Dependencies command...
[2025-02-17T13:20:05.810Z] 13:20:05 [Info] Searching items related to a build...
[2025-02-17T13:20:35.836Z] 13:20:35 [Info] Searching items related to a build...
[2025-02-17T13:20:36.086Z] 13:20:36 [Info] Searching items related to a build...
...
[2025-02-17T13:20:42.762Z] 13:20:42 [Error] Failed to close reader: remove D:\Jenkins\workspace\MyJob/jfrog-temp/jfrog.cli.temp.-1739798442-2443638522: The process cannot access the file because it is being used by another process.
[2025-02-17T13:20:42.763Z] 13:20:42 [Info] Trace ID for JFrog Platform logs: 88e4a11d7bf86906
[2025-02-17T13:20:42.763Z] 13:20:42 [Error] Failed to close reader: remove D:\Jenkins\workspace\MyJob/jfrog-temp/jfrog.cli.temp.-1739798442-2443638522: The process cannot access the file because it is being used by another process.
Couldn't execute 'jf' command. RuntimeException: Running 'jf' command failed with exit code 1

Reproduction steps

environment {
	JFROG_CLI_TEMP_DIR="$WORKSPACE/jfrog-temp/"
  }

jf "rt build-add-dependencies --project=proj --from-rt=true --server-id=artifactory --spec=./release-bundle.json MyBundle 58"

with release-bundle.json having many builds defned:

{
  "files": [
    {
      "build": "Build1",
      "project": "proj",
      "target": "modules/"
    },
    {
      "build": "Build2",
      "project": "proj",
      "target": "modules/"
    },
    {
      "build": "Build3",
      "project": "proj",
      "target": "modules/"
    },
    {
      "build": "Build4",
      "project": "proj",
      "target": "modules/"
    },
...
 ]
}

Note that it doesn't just happen with build-add-dependencies, it can also happen with download

Expected behavior

The commands succeed without failing on access to temporary files.

JFrog Artifactory version

7.98.13

JFrog Xray version

N/A

JFrog plugin version

1.5.8

JFrog CLI version

2.76.1

Operating system type and version

Windows 10 10.0.19045 Build 19045

JFrog Artifactory version

7.111.8

JFrog Xray version

N/A

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions