Skip to content

Commit

Permalink
Do not fail build in case of error while creating cache
Browse files Browse the repository at this point in the history
  • Loading branch information
repolevedavaj committed Feb 22, 2023
1 parent 9501a66 commit 929649e
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions src/main/java/jenkins/plugins/jobcacher/ArbitraryFileCache.java
Original file line number Diff line number Diff line change
Expand Up @@ -368,12 +368,17 @@ public void save(ObjectPath cachesRoot, Run<?, ?> build, FilePath workspace, Lau

logMessage("Creating cache...", listener);
long cacheCreationStartTime = System.nanoTime();
compressionMethod.getCacheStrategy().cache(resolvedPath, includes, excludes, useDefaultExcludes, cache, workspace);
if (isCacheValidityDecidingFileConfigured() && isOneCacheValidityDecidingFilePresent(workspace)) {
updateSkipCacheTriggerFileHash(cachesRoot, workspace);

try {
compressionMethod.getCacheStrategy().cache(resolvedPath, includes, excludes, useDefaultExcludes, cache, workspace);
if (isCacheValidityDecidingFileConfigured() && isOneCacheValidityDecidingFilePresent(workspace)) {
updateSkipCacheTriggerFileHash(cachesRoot, workspace);
}
long cacheCreationEndTime = System.nanoTime();
logMessage("Cache created in " + Duration.ofNanos(cacheCreationEndTime - cacheCreationStartTime).toMillis() + "ms", listener);
} catch (Exception e) {
logMessage("Failed to create cache", e, listener);
}
long cacheCreationEndTime = System.nanoTime();
logMessage("Cache created in " + Duration.ofNanos(cacheCreationEndTime - cacheCreationStartTime).toMillis() + "ms", listener);
}

private boolean isPathOutsideWorkspace(FilePath workspace) {
Expand Down

0 comments on commit 929649e

Please sign in to comment.