add pod index to container output message to make it easier to find in artifacts

This commit is contained in:
stefano 2019-11-04 17:12:50 +00:00
parent 2dab35c362
commit 718b7abb2f
3 changed files with 11 additions and 5 deletions

View File

@ -257,7 +257,7 @@ public class KubesTest extends DefaultTask {
client.pods().delete(createdPod);
client.persistentVolumeClaims().delete(pvc);
}
return new KubePodResult(resCode, podOutput, binaryResults);
return new KubePodResult(podIdx, resCode, podOutput, binaryResults);
});
} catch (Retry.RetryException e) {
throw new RuntimeException("Failed to build in pod " + podName + " (" + podIdx + "/" + numberOfPods + ") in " + numberOfRetries + " attempts", e);

View File

@ -5,11 +5,13 @@ import java.util.Collection;
public class KubePodResult {
private final int podIndex;
private final int resultCode;
private final File output;
private final Collection<File> binaryResults;
public KubePodResult(int resultCode, File output, Collection<File> binaryResults) {
public KubePodResult(int podIndex, int resultCode, File output, Collection<File> binaryResults) {
this.podIndex = podIndex;
this.resultCode = resultCode;
this.output = output;
this.binaryResults = binaryResults;
@ -26,4 +28,8 @@ public class KubePodResult {
public Collection<File> getBinaryResults() {
return binaryResults;
}
public int getPodIndex() {
return podIndex;
}
}

View File

@ -151,12 +151,12 @@ public class KubesReporting extends DefaultTask {
if (!containersWithNonZeroReturnCodes.isEmpty()) {
String reportUrl = new ConsoleRenderer().asClickableFileUrl(new File(destinationDir, "index.html"));
if (shouldPrintOutput){
if (shouldPrintOutput) {
containersWithNonZeroReturnCodes.forEach(podResult -> {
try {
System.out.println("\n##### CONTAINER OUTPUT START #####");
System.out.println("\n##### CONTAINER " + podResult.getPodIndex() + " OUTPUT START #####");
IOUtils.copy(new FileInputStream(podResult.getOutput()), System.out);
System.out.println("##### CONTAINER OUTPUT END #####\n");
System.out.println("##### CONTAINER " + podResult.getPodIndex() + " OUTPUT END #####\n");
} catch (IOException ignored) {
}
});