SMS Notification from UrbanCode Deploy
Hickmat 100000QA3T Visits (7163)
Whilst preparing for a recent demonstration of the capabilities of UrbanCode Deploy I decided to see if I could get an SMS notification issued to reflect the completion of a deploy process for an application. Why you may ask... well because I could really, not sure there is a real use case for this but it was fun to do
To start with I needed an application to work with and as my demonstration was focused around deploying BAR files to IBM Integration Bus I used the approach I outlined in my earlier blog entr
With this in place and the necessary resources created I was able to create a deployment flow for my Application which I tested and worked fine. With this all in place I set about looking at how to support the SMS notification. In order to manage the actual process of issuing the SMS I decided to re-use a NodeRED flow I'd created before (as part of the experimentation I did around IoT enabling the dispensing of Nespresso Coffee sachets - see HERE ). This leverage Twilio to send the message and so all I needed to do was create an HTTP listener at the front to allow me to invoke it via an HTTP call. I also defined the listener so that I could pass a message string to be sent. The NodeRED flow I created was as follows (I've shown some of the configuration details for the key nodes)
Next I needed to be able to call this from UrbanCode Deploy. The approach I took here was to create a "Generic" process which would use some Groovy code to call my SMS service running in NodeRED on Bluemix. The process its self was very simple and I defined it to have a single process parameter "Message" and aligned it to a specific resource which included an Agent which is installed an running on my base ThinkPad. The reason for having this resource defined was to ensure that an Agent with internet access was used by the notify process. The process its self just looks as follows:
The key part of this is the Groovy scrip being run in the Groovy Script step. I used my experience in creating a Cloudant Plugin for UCD as the base for this code and the code in the step is:
def uri = new URIBuilder(
int TWOMINS = 120*1000;
println "Setting socket time out to 2mins"
println "Shutdown HTTP Client Connection"
In this script you can see that I am inserting the "Message" property from the process invocation into the URI which I invoke to cause the NodeRED flow to fire. I also encode this string so spaces and other special characters can be supported.
The final step was to update my application deploy process to call this "Generic" notify process. This was a simple case of using the "Run Generic Process" step in the "Utilities" step. The resultant deployment process looks as follows:
Each of the "Notify" steps was configured to pass the appropriate message and also to remove default provided resource path to ensure the one configured in the generic process is used. For example the "Notify Success" step is configured as:
Now when I run the deploy process I get a nice little SMS notification to my phone (this is hard coded in my NodeRED flow but could be passed as another parameter from the process) indicating whether the deployment succeeded or failed.