diff --git a/apitest-commons/src/main/java/io/mosip/testrig/apirig/report/EmailableReport.java b/apitest-commons/src/main/java/io/mosip/testrig/apirig/report/EmailableReport.java index a3abc86536..825475092e 100644 --- a/apitest-commons/src/main/java/io/mosip/testrig/apirig/report/EmailableReport.java +++ b/apitest-commons/src/main/java/io/mosip/testrig/apirig/report/EmailableReport.java @@ -8,6 +8,9 @@ import java.io.InputStream; import java.io.InputStreamReader; import java.io.PrintWriter; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.StandardCopyOption; import java.text.NumberFormat; import java.time.LocalDate; import java.time.format.DateTimeFormatter; @@ -55,6 +58,7 @@ public class EmailableReport implements IReporter { private final StringBuilder buffer = new StringBuilder(); private String fileName = "emailable-report.html"; + private String mountPathForReport = ConfigManager.getMountPathForReport(); private static final String JVM_ARG = GlobalConstants.EMAILABLEREPORT2NAME; @@ -152,6 +156,14 @@ public void generateReport(List xmlSuites, List suites, String } else { LOG.info("Failed while pushing file to S3"); } + } else { + try { + Path mountFilePath = Path.of(mountPathForReport, newString); + Files.copy(newReportFile.toPath(), mountFilePath, StandardCopyOption.REPLACE_EXISTING); + LOG.info("Successfully copied report file to mount path: " + mountFilePath.toString()); + } catch (Exception e) { + LOG.error("Error occurred while copying file to mount path: " + e.getLocalizedMessage()); + } } } else { LOG.error("Renamed report file doesn't exist"); diff --git a/apitest-commons/src/main/java/io/mosip/testrig/apirig/utils/ConfigManager.java b/apitest-commons/src/main/java/io/mosip/testrig/apirig/utils/ConfigManager.java index ede4f4b2a6..c2cd7d78b6 100644 --- a/apitest-commons/src/main/java/io/mosip/testrig/apirig/utils/ConfigManager.java +++ b/apitest-commons/src/main/java/io/mosip/testrig/apirig/utils/ConfigManager.java @@ -126,6 +126,7 @@ public class ConfigManager { private static String AUTHCERTS_PATH = "authCertsPath"; private static String MOUNT_PATH_FOR_SCENARIO = "mountPathForScenario"; private static String MOCK_NOTIFICATION_CHANNEL = "mockNotificationChannel"; + private static String MOUNT_PATH_FOR_REPORT = "mountPathForReport"; private static String SERVER_ERRORS_TO_MONITOR = "serverErrorsToMonitor"; @@ -253,6 +254,7 @@ public class ConfigManager { private static String serverErrorsToMonitor; private static String mountPath; + private static String mountPathForReport; private static String authCertsPath; private static String mockNotificationChannel; private static String mountPathForScenario; @@ -369,6 +371,12 @@ public static void init() { mountPath = System.getenv(MOUNT_PATH) == null ? propsKernel.getProperty(MOUNT_PATH) : System.getenv(MOUNT_PATH); propsKernel.setProperty(MOUNT_PATH, mountPath); + + mountPathForReport = System.getenv(MOUNT_PATH_FOR_REPORT) == null + ? propsKernel.getProperty(MOUNT_PATH_FOR_REPORT) + : System.getenv(MOUNT_PATH_FOR_REPORT); + propsKernel.setProperty(MOUNT_PATH_FOR_REPORT, mountPathForReport); + mockNotificationChannel = System.getenv(MOCK_NOTIFICATION_CHANNEL) == null ? propsKernel.getProperty(MOCK_NOTIFICATION_CHANNEL) @@ -643,6 +651,10 @@ public static String getmountPath() { return mountPath; } + public static String getMountPathForReport() { + return mountPathForReport; + } + public static String getmountPathForScenario() { return mountPathForScenario; }