jenkinsci / jenkinsci/jfrog-plugin

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

Open
#48 0 comments 0 reactions 0 assignees View on GitHub
bug
Dominant language
Java
Stars
16
Forks
85
PR merge metrics
No merged PRs in 30d

Description

### Describe the bug

When running the following command:

```groovy
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:

```sh
[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

```groovy
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:
```json
{
"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 plugin version

1.5.8

### JFrog CLI version

2.73.2

### Operating system type and version

Windows 10 10.0.19045 Build 19045

### JFrog Artifactory version

7.98.13

### JFrog Xray version

N/A

Contributor guide

Open the contributing guide

Research direction

Reproduce the failure on Windows 10 using JFrog plugin 1.5.8, JFrog CLI 2.73.2, JFROG_CLI_TEMP_DIR, and the supplied build-add-dependencies or download commands. Start by tracing the plugin's command invocation and temporary-file handling; done means the commands complete without temporary-file access errors.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
devops
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.