Skip to content
Permalink
Browse files

[JENKINS-50428] Take into account the now configurable location for t…

…asks logging
  • Loading branch information...
batmat committed Mar 28, 2018
1 parent 7dff475 commit e0bf6ba8534d8ba9e06a4d6349e714563b1daa46
Showing with 18 additions and 2 deletions.
  1. +18 −2 src/main/java/com/cloudbees/jenkins/support/impl/JenkinsLogs.java
@@ -46,7 +46,7 @@
private static final Logger LOGGER = Logger.getLogger(JenkinsLogs.class.getName());
private static final int MAX_ROTATE_LOGS = Integer.getInteger(JenkinsLogs.class.getName() + ".MAX_ROTATE_LOGS", 9);
private final Map<String,LogRecorder> logRecorders = Jenkins.getInstance().getLog().logRecorders;
private final File customLogs = new File(new File(Jenkins.getInstance().getRootDir(), "logs"), "custom");
private final File customLogs = new File(getLogsRoot(), "custom");

@NonNull
@Override
@@ -111,7 +111,7 @@ private void addOtherMasterLogs(Container result) {
result.add(new FileContent("other-logs/" + f.getName(), f));
}
}
File logs = new File(jenkins.getRootDir(), "logs");
File logs = getLogsRoot();
files = logs.listFiles(ROTATED_LOGFILE_FILTER);
if (files != null) {
for (File f : files) {
@@ -128,6 +128,22 @@ private void addOtherMasterLogs(Container result) {
}
}

/**
* Returns the root directory for logs (historically always found under <code>$JENKINS_HOME/logs</code>.
* Configurable since Jenkins 2.114.
*
* @see hudson.triggers.SafeTimerTask#LOGS_ROOT_PATH_PROPERTY
* @return the root directory for logs.
*/
private File getLogsRoot() {
final String overriddenLogsRoot = System.getProperty("hudson.triggers.SafeTimerTask.logsTargetDir");
if (overriddenLogsRoot == null) {
return new File(Jenkins.get().getRootDir(), "logs");
} else {
return new File(overriddenLogsRoot);
}
}

/**
* Adds {@link Jenkins#logRecords} (from core) into the support bundle.
*

0 comments on commit e0bf6ba

Please sign in to comment.
You can’t perform that action at this time.