|
@@ -1698,6 +1698,7 @@ protected final void execute(@Nonnull RunExecution job) { |
|
|
if(result!=null) |
|
|
return; // already built. |
|
|
|
|
|
OutputStream logger = null; |
|
|
StreamBuildListener listener=null; |
|
|
|
|
|
runner = job; |
|
@@ -1716,7 +1717,8 @@ protected final void execute(@Nonnull RunExecution job) { |
|
|
charset = computer.getDefaultCharset(); |
|
|
this.charset = charset.name(); |
|
|
} |
|
|
listener = createBuildListener(job, listener, charset); |
|
|
logger = createLogger(); |
|
|
listener = createBuildListener(job, logger, charset); |
|
|
listener.started(getCauses()); |
|
|
|
|
|
Authentication auth = Jenkins.getAuthentication(); |
|
@@ -1798,23 +1800,32 @@ protected final void execute(@Nonnull RunExecution job) { |
|
|
try { |
|
|
getParent().logRotate(); |
|
|
} catch (Exception e) { |
|
|
LOGGER.log(Level.SEVERE, "Failed to rotate log",e); |
|
|
} |
|
|
LOGGER.log(Level.SEVERE, "Failed to rotate log",e); |
|
|
} |
|
|
} finally { |
|
|
onEndBuilding(); |
|
|
if (logger != null) { |
|
|
try { |
|
|
logger.close(); |
|
|
} catch (IOException x) { |
|
|
LOGGER.log(Level.WARNING, "failed to close log for " + Run.this, x); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
private StreamBuildListener createBuildListener(@Nonnull RunExecution job, StreamBuildListener listener, Charset charset) throws IOException, InterruptedException { |
|
|
private OutputStream createLogger() throws IOException { |
|
|
// don't do buffering so that what's written to the listener |
|
|
// gets reflected to the file immediately, which can then be |
|
|
// served to the browser immediately |
|
|
OutputStream logger; |
|
|
try { |
|
|
logger = Files.newOutputStream(getLogFile().toPath(), StandardOpenOption.CREATE, StandardOpenOption.APPEND); |
|
|
return Files.newOutputStream(getLogFile().toPath(), StandardOpenOption.CREATE, StandardOpenOption.APPEND); |
|
|
} catch (InvalidPathException e) { |
|
|
throw new IOException(e); |
|
|
} |
|
|
} |
|
|
|
|
|
private StreamBuildListener createBuildListener(@Nonnull RunExecution job, OutputStream logger, Charset charset) throws IOException, InterruptedException { |
|
|
RunT build = job.getBuild(); |
|
|
|
|
|
// Global log filters |
|
@@ -1830,8 +1841,7 @@ private StreamBuildListener createBuildListener(@Nonnull RunExecution job, Strea |
|
|
} |
|
|
} |
|
|
|
|
|
listener = new StreamBuildListener(logger,charset); |
|
|
return listener; |
|
|
return new StreamBuildListener(logger,charset); |
|
|
} |
|
|
|
|
|
/** |
|
|