I am trying to integrate a curl command within this java file to execute a Curl command tied into the message that "The Validation Test case failed", how do I integrate this to only send when the job fails and the email is triggered?
public class SendToMetricPipeline {
public static void sendMetric(String status, String environment, String dashboard, String remarks) {
TimeZone tz = TimeZone.getTimeZone("UTC");
DateFormat df = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'");
df.setTimeZone(tz);
String today = df.format(new Date());
...
if (postResult) {
System.out.println("Data Successfully posted");
} else {
System.out.println("Data not sent");
if (environment.equalsIgnoreCase("prod")) {
EmailUtil.sendEmail("Application Validation Post Results Failed", " Validation Post Results Failed");
}
}
//Send Email when the test case Fail
if (status == "failed") {
System.out.println("Validation Test Failed");
if (environment.equalsIgnoreCase("prod")) {
EmailUtil.sendEmail("The Validation Test case failed", " Validation Test Failed");
}
}
}
}