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

[JENKINS-52692,JENKINS-38313] - External task logging API #3557

Closed
Closed
Changes from 1 commit
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
4c6355b
Initial interface of LoggingMethod.
Sep 17, 2016
28386a5
Skeleton implementation of the remote logging extension point
oleg-nenashev Sep 17, 2016
79ef4c0
HACK: Get rid of the special symbol in order to be able to process su…
oleg-nenashev Sep 17, 2016
69a7ef4
Polish Javadoc a bit
oleg-nenashev Sep 18, 2016
5c287b3
Hide launcher complexity from plugin.
Sep 19, 2016
febb8bf
Update LoggingDefinitionLauncherWrapper.java
xyan0607 Sep 28, 2016
b0d8e64
Update LoggingMethod.java
xyan0607 Sep 28, 2016
948db76
Merge pull request #5 from xyan0607/jw-hackaton-external-logging
oleg-nenashev Oct 4, 2016
5224058
Save the progress
oleg-nenashev Oct 12, 2016
1c37b73
Merge commit 'ac05680bb6eba6efc8a825ba59fda6fbad753d22' into external…
oleg-nenashev Feb 2, 2018
5ffea98
Merge branch 'master' into external-task-logging
oleg-nenashev Jul 6, 2018
e64d206
[JENKINS-38313] - Facelift the implementation
oleg-nenashev Jul 9, 2018
d5c4651
[JENKINS-38313] - Add the LogBrowser stub
oleg-nenashev Jul 9, 2018
02fd209
[JENKINS-38313] - References to log storages and browsers are now per…
oleg-nenashev Jul 16, 2018
86d8e43
Cleanup FindBugs + Beta annotations
oleg-nenashev Jul 16, 2018
21aae74
Revert custom patches
oleg-nenashev Jul 16, 2018
d26d38a
[JENKINS-38313] - Adjust initialization logic so that Pipeline Operat…
oleg-nenashev Jul 23, 2018
5f6213e
[JENKINS-38313] - Move Launcher wrapping logic to External Logging AP…
oleg-nenashev Jul 23, 2018
da4441a
[JENKINS-38313] - Refactor LoggingMethod API to simplify the implemen…
oleg-nenashev Jul 23, 2018
b193607
[JENKINS-38313] - Align TaskListener and BuildListener API in Logging…
oleg-nenashev Jul 23, 2018
a2e0317
[JENKINS-38313] - CloseableStreaMBuildListener is not required
oleg-nenashev Jul 23, 2018
48d03e0
[JENKINS-38313] - Cleanup formatting, imports and licenses
oleg-nenashev Jul 23, 2018
f56ea7a
Add TODO from @jglick, unrestrict API
oleg-nenashev Jul 26, 2018
ac9633a
Merge commit '25da480fab1da7d2a01ab68a56faf00cae0c23b1' into external…
oleg-nenashev Jul 31, 2018
e15bdc1
Merge branch 'master' into external-task-logging
oleg-nenashev Aug 3, 2018
62024d7
[JENKINS-38313] - Move LogBrowser#getFile() default caching implement…
oleg-nenashev Aug 3, 2018
7ebcb15
[JENKINS-38313] - Introduce API For Deleting logs
oleg-nenashev Aug 3, 2018
70e154e
[JENKINS-38313] - Adapt NoopLogFile to the new API
oleg-nenashev Aug 3, 2018
f996af4
Merge commit '7b2698db89183b4d701107485db61eb36442ac25' into external…
oleg-nenashev Aug 6, 2018
198fc7a
Merge branch 'master' into external-task-logging
oleg-nenashev Feb 1, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
[JENKINS-38313] - Introduce API For Deleting logs
oleg-nenashev committed Aug 3, 2018
commit 7ebcb15b032f892c1415f776eab012b0dc7ff43d
16 changes: 16 additions & 0 deletions core/src/main/java/hudson/model/Run.java
Original file line number Diff line number Diff line change
@@ -1505,6 +1505,17 @@ public File getLogFile() {
}
}

/**
* Deletes the log in the storage.
* @return {@code true} if the log was deleted.
* {@code false} if Log deletion is not supported.
* @throws IOException Failed to delete the log.
* @since TODO
*/
public boolean deleteLog() throws IOException {
return getLogBrowser().deleteLog();
}

/**
* Returns an input stream that reads from the log file.
* It will use a gzip-compressed log file (log.gz) if that exists.
@@ -1627,6 +1638,11 @@ public void delete() throws IOException {
deleteArtifacts();
} // for StandardArtifactManager, deleting the whole build dir suffices

final LogBrowser browser = getLogBrowser();
if (browser instanceof FileLogBrowser) {
browser.deleteLog();
} // for standard FileLogBrowser, deleting the whole build dir suffices

synchronized (this) { // avoid holding a lock while calling plugin impls of onDeleted
File tmp = new File(rootDir.getParentFile(),'.'+rootDir.getName());

8 changes: 8 additions & 0 deletions core/src/main/java/jenkins/model/logging/LogBrowser.java
Original file line number Diff line number Diff line change
@@ -127,4 +127,12 @@ public List<String> getLog(int maxLines) throws IOException {
@Nonnull
public abstract File getLogFile() throws IOException;

/**
* Deletes the log in the storage.
* @return {@code true} if the log was deleted.
* {@code false} if Log deletion is not supported.
* @throws IOException Failed to delete the log.
*/
public abstract boolean deleteLog() throws IOException;

}
17 changes: 17 additions & 0 deletions core/src/main/java/jenkins/model/logging/impl/FileLogBrowser.java
Original file line number Diff line number Diff line change
@@ -48,6 +48,7 @@
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;

/**
@@ -91,6 +92,22 @@ public AnnotatedLargeText stepLog(@CheckForNull String stepId, boolean b) {
);
}

@Override
public boolean deleteLog() throws IOException {
File logFile = getLogFileOrFail(loggable);
if (logFile.exists()) {
try {
Files.delete(logFile.toPath());
} catch (Exception ex) {
throw new IOException("Failed to delete " + logFile, ex);
}
} else {
LOGGER.log(Level.FINE, "Trying to delete Log File of {0} which does not exist: {1}",
new Object[] {loggable, logFile});
}
return true;
}

@Override
public InputStream getLogInputStream() throws IOException {
File logFile = getLogFileOrFail(loggable);