Skip to main content
DevOps Image

This post is from the XebiaLabs blog and has not been updated since the original publish date.

Last Updated Mar 01, 2015 — DevOps Expert

Well Formatted E-Mail Notifications In XL Deploy

DevOps

As a part of your XL Deploy automation strategy, you might want to have XL Deploy send out emails during some state changes of the deployment process.  XL Deploy uses FreeMarker templates to format and deliver emails when triggered in the deployment process.  XL Deploy can provide emails to various groups in your organization.  The emails sent out can be customized to different audiences in your organization as well.  In this article I will show you how to configure XL Deploy to send out emails during the deployment process. For each deployment we want to collect some additional information that we are going to put in these emails.  To do that we need to make some changes to the synthetic.xml file as follows:Screen Shot 2015-02-25 at 1.23.14 PMWe can also use some of this information to determine if a deployment can continue in its' pipeline.  Once the changes are made to the synthetic.xml file, restart the XL Deploy server. We will need to tell XL Deploy where there is an SMTP server that emails can be set to.  In my environment (linux) I can create my own SMTP server and configure it as follows:Screen Shot 2015-02-24 at 1.21.19 PMWe can call the mail server "DefaultSmtpServer". Now we will need to create a template for the email that will be sent out.  Under Configuration you can create folders for organization as you like, but then we will create a trigger.EmailNotification as follows:Screen Shot 2015-02-24 at 1.24.27 PMWe don't need to change the "From Address" as that will be picked up from the mail.SmtpServer.  We see a little bit of the FreeMarker templating in the subject line of the email.  For now notice that I selected that we should send the content of our emails as HTML.  I'll talk more about this later. Emails are sent out on a triggered event.  In order to set up a task trigger, we will need to carefully select the state transitions so our trigger will fire when we need it to.  The transitions we will connect emails to today are as follows:

  • For Deployment Failure: States should be from EXECUTING to STOPPED.
  • For Deployment Complete: States should be from ANY to EXCUTED
Next we will need to create a Trigger.  Under Configuration folder create a new Trigger as follows:Screen Shot 2015-02-24 at 1.05.48 PMCreate a similar trigger for deployment failures too. In the case of a deployment failure all of the steps will not have been completed.  For example, the completionDate property will not be set.  The FreeMarker template will need to take that into account. We need to add the deployment triggers to the environments that should trigger emails.  Lets configure a test environment to send out emails.  In XL Deploy we will navigate to our TEST environment and edit it.Screen Shot 2015-02-25 at 8.07.06 AMAdd all of the triggers you want to fire during deployments to this environment.  I have different triggers for Successful and Failed Deployments. The additional objects that were added to the synthetic.xml are now visible in the Deployment Checklist for the udm.DeploymentPackage.  We can set these values manually or by a script.  Now the application tab of the application version looks as follows:Screen Shot 2015-02-24 at 2.49.44 PMNow we can create the FreeMarker template for the emails that XL Deploy will send out.  These emails will contain information about the deployment as well as the information in the Deployment Checklist. In my environment we are going to present a little information about the change tickets that may be created during the push of this version from one environment to the next.  Lets say that all code moves will have a master change ticket associated with them and that each move will have a sub ticket number associated with it.  In our HTML email template I can add the following:Screen Shot 2015-02-25 at 1.24.29 PMThis will create a little table with the change tickets.  So this is how we can add some of the additional data about the deploy outside of the actual deployment steps.  Now that we have this information in our email, lets add some information about the actual deployment steps.  To do that we will add another HTML table with some of the deployment step information as follows:Screen Shot 2015-02-25 at 1.25.24 PMThis part of the FreeMarker document iterates over all of the steps in our deployment. We can now do a deploy and we should get an email as follows:Screen Shot 2015-02-24 at 10.31.18 AMYou can find the synthetic.xml snipit and the full FreeMarker templates in my Blog Git Repo.  References:
  1. https://support.xebialabs.com/entries/27030538-Configuring-email-notifications-with-XL Deploy
  2. https://github.com/zvercodebender/xebialabs-blog-files/tree/master/well_formated_email_notifications
  3. https://docs.xebialabs.com/generated/XL Deploy/4.5.x/rest-api/com.xebialabs.XL Deploy.engine.api.execution.StepState.html
  4. http://docs.xebialabs.com/releases/latest/XL Deploy/triggerPluginManual.html#task-state-transitions
  5. http://docs.xebialabs.com/releases/latest/XL Deploy/triggerPluginManual.html#triggertasktrigger
  6. http://freemarker.org/
 

More from the Blog

View more
Jun 10, 2021

Desilo DevOps: The power of bringing all your tools and data into one view

DevOps
When discussing value stream management (VSM), our resources talk a lo ...
Read More
Jun 07, 2021

"How do I get started?" Key steps to improving your end-to-end DevOps process

DevOps
There is an extraordinary variety of DevOps solutions available on the ...
Read More
May 24, 2021

Integrate your DevOps toolchain, simplify your life

DevOps
Organizations can view the entirety of the tools and platforms they us ...
Read More
May 17, 2021

Why Companies in Competitive Industries Adjusted Better During COVID-19

DevOps
As we continue to assess the dramatic effects of the global COVID-19 p ...
Read More
Contact Us