in s3-artifact-storage-server/src/main/java/jetbrains/buildServer/artifacts/s3/cleanup/S3CleanupExtension.java [129:151]
public void cleanupBuildsData(@NotNull BuildCleanupContext cleanupContext) throws CleanupInterruptedException {
//noinspection unchecked
Map<Long, BuildStorageInfo> buildStorageInfos = (Map<Long, BuildStorageInfo>)cleanupContext.getExtensionData(BUILD_STORAGE_INFOS_KEY);
if (buildStorageInfos == null) {
throw new IllegalStateException("Extension data should have been initialized during `prepareBuildsData` stage.");
}
for (long buildId : cleanupContext.getBuildIds()) {
BuildStorageInfo buildStorageInfo = buildStorageInfos.remove(buildId);
if (buildStorageInfo != null) {
cleanupContext.getCleanupState().throwIfInterrupted();
SFinishedBuild build = buildStorageInfo.myBuild;
try {
doClean(cleanupContext, build, buildStorageInfo.myPathPrefix, buildStorageInfo.myPathsToDelete, buildStorageInfo.myStorageSettings);
} catch (IOException e) {
CLEANUP.warn("Failed to remove S3 artifacts: " + e.getMessage());
cleanupContext.onBuildCleanupError(this, build, "Failed to remove S3 artifacts due to IO error.");
} catch (RuntimeException e) {
CLEANUP.warn("Failed to remove S3 artifacts: " + e.getMessage());
cleanupContext.onBuildCleanupError(this, build, "Failed to remove S3 artifacts due to unexpected error.");
}
}
}
}