Skip to content

Commit

Permalink
Add fallback jenkins.war location for official docker image (#520)
Browse files Browse the repository at this point in the history
Co-authored-by: Tim Jacomb <timjacomb1@gmail.com>
  • Loading branch information
Jagrutiti and timja committed Feb 2, 2024
1 parent e8015dc commit 820da1e
Showing 1 changed file with 15 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
package io.jenkins.tools.pluginmanager.config;

import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import java.io.File;
import java.net.MalformedURLException;
import java.net.URL;
import java.nio.file.Path;
import java.nio.file.Paths;

// see https://github.com/spotbugs/spotbugs/issues/1958#issuecomment-1056685201
@SuppressFBWarnings(value = "DMI_HARDCODED_ABSOLUTE_FILENAME", justification = "dumb rule that makes no sense")
public class Settings {
public static final String DEFAULT_PLUGIN_DIR_LOCATION;
public static final String DEFAULT_WAR;
Expand All @@ -20,6 +24,10 @@ public class Settings {
public static final Path DEFAULT_CACHE_PATH;
public static final HashFunction DEFAULT_HASH_FUNCTION = HashFunction.SHA256;

private static final String DOCKER_IMAGE_WAR_LOCATION = "/usr/share/jenkins/jenkins.war";

private static final String PACKAGING_WAR_LOCATION = "/usr/share/java/jenkins.war";

static {
String cacheBaseDir = System.getProperty("user.home");
if (cacheBaseDir == null) {
Expand Down Expand Up @@ -50,7 +58,13 @@ public class Settings {
DEFAULT_WAR = "C:\\ProgramData\\Jenkins\\jenkins.war";
DEFAULT_PLUGIN_DIR_LOCATION = "C:\\ProgramData\\Jenkins\\Reference\\Plugins";
} else {
DEFAULT_WAR = "/usr/share/java/jenkins.war";
File file = new File(DOCKER_IMAGE_WAR_LOCATION);
if (file.exists()) {
DEFAULT_WAR = DOCKER_IMAGE_WAR_LOCATION;
} else {
DEFAULT_WAR = PACKAGING_WAR_LOCATION;
}

DEFAULT_PLUGIN_DIR_LOCATION = "/usr/share/jenkins/ref/plugins";
}
}
Expand Down

0 comments on commit 820da1e

Please sign in to comment.