...
Expand |
---|
title | Email Failed Logs Script |
---|
|
Code Block |
---|
| import flexagon.ff.adfextmodel2.commonpojo.model.pojos.communication.EmailAttachment;
import groovy.json.JsonOutput;
//Carry out any custom action you wish for this event. Check out the documentation for reference or ideas.
//Optionally filter out events you dont want to execute by returning false on the filter script tab.
def listenerName = "Email Failed Logs";
LOG.info("Running listener: ${listenerName}");
//retrieve plugin log input stream map
def logs = FLEXDEPLOY.getPluginLogInputStreams(EVENT.payload.workflowExecutionId);
def attachments = [];
//for each entry create and add a new attachment
//prior to 5.4.0.1 logs would be a list instead of a map
logs.each { log ->
attachments.add(new EmailAttachment(log.value,"${log.key}.txt","text/plain"));
}
LOG.info("Sending email with ${attachments.size()} attachments.");
//send email
def subject = "${EVENT.payload.project.projectName} failed in ${EVENT.payload.environment.environmentName}";
def message = JsonOutput.prettyPrint(JsonOutput.toJson(EVENT.payload));
def recipients = ["my.user@domain.com"];
EMAIL.sendEmail(subject, message, recipients, attachments);
LOG.setMessage("Sent email message to ${recipients}"); |
|
...
You may want to change a package’s status to completed to indicate it successfully deployed to its final environment. This webhook handles changing the status for you using the Workflow Completed Event. You could also update the filter to only update the status for certain projects, releases, instances, etc. The listener also handles removing the package from its release first, as a package cannot be marked completed if it’s in an active release.
Expand |
---|
|
Code Block |
---|
| def releaseName = EVENT.payload.release.releaseName
def projectId = EVENT.payload.project.projectId
def packageName = EVENT.payload.packageName
if (releaseName != null)
{
FLEXDEPLOY.removeProjectsFromRelease(releaseName, [new flexagon.fd.model.pojos.rest.release.ReleaseProjectsPojo(projectId, packageName, false)])
}
FLEXDEPLOY.updatePackageStatus(projectId, packageName, "COMPLETED") |
|
...