Skip to content

Commit

Permalink
Guard against missing file in CI upload (elastic#117889)
Browse files Browse the repository at this point in the history
Somehow files can be lost before the build ends up uploading them,
presumable from temporarily file deletion after tests complete. This
commit guards against this case so that the build will not completely
fail, but instead log a warning.
  • Loading branch information
rjernst authored Dec 3, 2024
1 parent 00a1222 commit c1a9d44
Showing 1 changed file with 9 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@
import org.gradle.api.provider.Property;
import org.gradle.api.tasks.Input;
import org.jetbrains.annotations.NotNull;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
Expand All @@ -47,6 +49,8 @@

public abstract class ElasticsearchBuildCompletePlugin implements Plugin<Project> {

private static final Logger log = LoggerFactory.getLogger(ElasticsearchBuildCompletePlugin.class);

@Inject
protected abstract FlowScope getFlowScope();

Expand Down Expand Up @@ -241,8 +245,11 @@ private static void createBuildArchiveTar(List<File> files, File projectDir, Fil
tOut.setLongFileMode(TarArchiveOutputStream.LONGFILE_GNU);
tOut.setBigNumberMode(TarArchiveOutputStream.BIGNUMBER_STAR);
for (Path path : files.stream().map(File::toPath).toList()) {
if (!Files.isRegularFile(path)) {
throw new IOException("Support only file!");
if (Files.exists(path) == false) {
log.warn("File disappeared before it could be added to CI archive: " + path);
continue;
} else if (!Files.isRegularFile(path)) {
throw new IOException("Support only file!: " + path);
}

long entrySize = Files.size(path);
Expand Down

0 comments on commit c1a9d44

Please sign in to comment.