Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Stop cleaning the plugin directory by default + Add an opt-in flag for cleaning the target plugin directory + Restore the --list command #239

Merged
merged 11 commits into from Dec 9, 2020
Merged
Expand Up @@ -39,6 +39,11 @@ class CliOptions {
handler = FileOptionHandler.class)
private File pluginDir;

@Option(name = "--clean-download-directory",
usage = "If sets, cleans the plugin download directory before plugin installation. " +
"Otherwise the tool performs plugin download and reports compatibility issues, if any.")
private boolean cleanPluginDir;

@Option(name = "--plugins", aliases = {"-p"}, usage = "List of plugins to install, separated by a space",
handler = StringArrayOptionHandler.class)
private String[] plugins = new String[0];
Expand Down Expand Up @@ -144,6 +149,7 @@ Config setup() {
return Config.builder()
.withPlugins(getPlugins())
.withPluginDir(getPluginDir())
.withCleanPluginsDir(isCleanPluginDir())
.withJenkinsUc(getUpdateCenter())
.withJenkinsUcExperimental(getExperimentalUpdateCenter())
.withJenkinsIncrementalsRepoMirror(getIncrementalsMirror())
Expand Down Expand Up @@ -214,6 +220,10 @@ private File getPluginDir() {
return new File(Settings.DEFAULT_PLUGIN_DIR_LOCATION);
}

public boolean isCleanPluginDir() {
return cleanPluginDir;
}

@CheckForNull
private VersionNumber getJenkinsVersion() {
if (jenkinsVersion != null) {
Expand Down
Expand Up @@ -67,12 +67,6 @@ public static void main(String[] args) throws IOException {
return;
}

if (cfg.isShowPluginsToBeDownloaded()) {
System.out.println("The --list flag is currently unsafe and is temporarily disabled, " +
"see https://github.com/jenkinsci/plugin-installation-manager-tool/issues/173");
return;
}

pm.start();
} catch (Exception e) {
if (options.isVerbose()) {
Expand Down
Expand Up @@ -20,6 +20,7 @@
*/
public class Config {
private File pluginDir;
private boolean cleanPluginDir;
private boolean showWarnings;
private boolean showAllWarnings;
private boolean showAvailableUpdates;
Expand Down Expand Up @@ -49,6 +50,7 @@ public class Config {

private Config(
File pluginDir,
boolean cleanPluginDir,
boolean showWarnings,
boolean showAllWarnings,
boolean showAvailableUpdates,
Expand All @@ -67,6 +69,7 @@ private Config(
boolean skipFailedPlugins,
OutputFormat outputFormat) {
this.pluginDir = pluginDir;
this.cleanPluginDir = cleanPluginDir;
this.showWarnings = showWarnings;
this.showAllWarnings = showAllWarnings;
this.showAvailableUpdates = showAvailableUpdates;
Expand All @@ -90,6 +93,10 @@ public File getPluginDir() {
return pluginDir;
}

public boolean isCleanPluginDir() {
return cleanPluginDir;
}

public boolean isShowWarnings() {
return showWarnings;
}
Expand Down Expand Up @@ -165,6 +172,7 @@ public static Builder builder() {

public static class Builder {
private File pluginDir;
private boolean cleanPluginDir;
private boolean showWarnings;
private boolean showAllWarnings;
private boolean showAvailableUpdates;
Expand All @@ -191,6 +199,11 @@ public Builder withPluginDir(File pluginDir) {
return this;
}

public Builder withCleanPluginsDir(boolean cleanPluginDir) {
this.cleanPluginDir = cleanPluginDir;
return this;
}

public Builder withShowWarnings(boolean showWarnings) {
this.showWarnings = showWarnings;
return this;
Expand Down Expand Up @@ -284,6 +297,7 @@ public Builder withOutputFormat(OutputFormat outputFormat) {
public Config build() {
return new Config(
pluginDir,
cleanPluginDir,
showWarnings,
showAllWarnings,
showAvailableUpdates,
Expand Down