Skip to content

Commit c1a9d44

Browse files
authored
Guard against missing file in CI upload (#117889)
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.
1 parent 00a1222 commit c1a9d44

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/ElasticsearchBuildCompletePlugin.java

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@
2929
import org.gradle.api.provider.Property;
3030
import org.gradle.api.tasks.Input;
3131
import org.jetbrains.annotations.NotNull;
32+
import org.slf4j.Logger;
33+
import org.slf4j.LoggerFactory;
3234

3335
import java.io.BufferedInputStream;
3436
import java.io.BufferedOutputStream;
@@ -47,6 +49,8 @@
4749

4850
public abstract class ElasticsearchBuildCompletePlugin implements Plugin<Project> {
4951

52+
private static final Logger log = LoggerFactory.getLogger(ElasticsearchBuildCompletePlugin.class);
53+
5054
@Inject
5155
protected abstract FlowScope getFlowScope();
5256

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

248255
long entrySize = Files.size(path);

0 commit comments

Comments
 (0)