jenkinsci / jenkinsci/plugin-installation-manager-tool

Unclear behavior/documentation wrt cleaning plugin directory

Open
#455 3 comments 3 reactions 0 assignees View on GitHub
bug
Dominant language
Java
Stars
463
Forks
228
Avg merge
31m
Merged PRs (30d)
15

Description

### Jenkins and plugins versions report

**tested with: jenkins-plugin-manager-2.12.8.jar**

Several inconsistencies and bugs regarding the cleaning of plugin directory.

1. the readme states for `--plugin-download-directory` that "The directory will be first deleted, then recreated". However this is not the case.
2. there is an _undocumented_ `--clean-download-directory` flag in the code [here](https://github.com/jenkinsci/plugin-installation-manager-tool/blob/master/plugin-management-cli/src/main/java/io/jenkins/tools/pluginmanager/cli/CliOptions.java#L44-L47). However the implementation is broken. The directory contents is deleted. The directory itself is left in place. That by itself is not a problem. However the code then tries to re-create the plugin dir and fails with an "The plugin directory already exists" error.

At this point it is not even clear what the intended behavior is. The documentation and code are inconsistent. Having the clean-up behavior controlled by a cli-flag seems reasonable and gives most flexibility to users. If that is the goal, needed steps would be:
- fix documentation of `--plugin-download-directory` flag.
- add documentation for `--clean-download-directory`
- fix implementation of --clean-download-directory to not error out if the directory exists.

### What Operating System are you using (both controller, and any agents involved in the problem)?

all

### Reproduction steps

### Case 1:
```
mkdir plugins
touch plugins/xxx

# per documentation, this should delete and re-create 'plugins' directory
java -jar ../jenkins-plugin-manager.jar -d plugins --verbose --jenkins-version 2.277.4

ls plugins/xxx
```

### Case 2:
```
mkdir plugins

# per documentation, this should delete and re-create 'plugins' directory
java -jar ../jenkins-plugin-manager.jar -d plugins --jenkins-version 2.277.4 --clean-download-directory
-> The plugin directory already exists: plugins
```

### Expected Results

### Case 1:
plugin directory is deleted and recreated as stated in the documentation _or_ documentation needs to be adapted for the actual behavior

### Case 2:
expect no "The plugin directory already exists: plugins" error

### Actual Results

### Case 1:
plugin directory is not deleted

### Case 2:
command fails with "The plugin directory already exists: plugins"

### Anything else?

_No response_

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.