Some alerts are more important than others and there are times when it is very important that the message is received. When I was a Jira admin (way back when) we had a problem with our server and it would randomly restart. I wanted to know when this happened because sometimes Jira would start correctly, sometimes it wouldn’t. This was way back in the days of Jira 5 (I think). I don’t remember exactly what the issue was with the server but I do know what I did to solve the problem of getting notified of when it went down, I sent myself a text message.
With the use of Start and Stop scripts you can configure Power Scripts to run a script whenever Jira starts or stops. Note that this is assuming that Jira starts/stops correctly. If the server crashes the procedures to shut JVM instance down get skipped. So, if you configure a script to run when Jira starts it tends to be more reliable. If you install Jira to run as a service it will automatically start when the server reboots and the script will run whenever the server crashes and restarts. That is what I used it for anyway, perhaps you have something else in mind. Either way the steps to send the message will be the same.
For a long time SIL had SMS capabilities built directly within it. However, these SMS gateways had to be configured with each service provider. That way has become obsolete now that (just about) every carrier has an email to SMS service that will automatically convert an email to a text message if the email is sent to the right address. Each provider has a different email address but they all basically work the same way. The phone number servers as the username and then each carrier has a unique domain. See a list of some of the most common carriers below.
T-Mobile – number@tmomail.net
Virgin Mobile – number@vmobl.com
AT&T – number@txt.att.net
Sprint – number@messaging.sprintpcs.com
Verizon – number@vtext.com
Tracfone – number@mmst5.tracfone.com
Ting – number@message.ting.com
Boost Mobile – number@myboostmobile.com
U.S. Cellular – number@email.uscc.net
Metro PCS – number@mymetropcs.com
But, before you run off and start creating a script to do something similar there are some considerations to be made. Like, how to associate the phone number and carrier to a user. You could just write a script like this:
sendEmail("0123456789@phonecompany.com", {}, "Jira has restarted!", "The Jira server has been restarted. Maybe you should check it out?");
But, I wouldn’t recommend it. Maybe you don’t want your phone number out there for everyone to see. Plus, what happens when another admin wants this super cool feature? You would need to put there info in the script as well. What happens when it becomes 20? Suddenly you make everyone's personal information available for everyone to see.
One option would be to use persistent variables. That way the personal information would be a little more out of sight and would not be stored in the script.
persistent string [] textUsers; JEmailMessage email; email.to = textUsers; email.subject = "Jira has restarted!"; email.message = "The Jira server has been restarted. Maybe you should check it out?"; sendEmail(email);
This method is okay, however, personally I like to build solutions that don’t require the script to me modified in order to maintain them. I also like to keep user data with the user. The way I prefer to do, which admittedly, is a little more involved, is to store the information as a user property.
Then the users who whish to receive the text messages can be added to a group. The script will loop through the users in the group and get the emails from the users properties.
string [] smsEmails; for(string user in usersInGroups("SMS Recipients", true)) { string email = getUserProperty(user, "SMS Email"); if(isNotNull(email)) { smsEmails += email; } } JEmailMessage email; email.to = smsEmails; email.subject = "Jira has restarted!"; email.message = "The Jira server has been restarted. Maybe you should check it out?"; sendEmail(email);
Yes, it is a little more code but in this way a users email can easily be updated in the Jira admin UI and not the script. And, users can easily be added or removed from the user group.
Organizing scripts in the SIL Manager is one of those things that everyone does wrong when they first start using the tools. Assume that you will end up with hundreds of script because you are so fond of all the magical things they can do to save you time that you keep creating them because you can’t get enough of them (usually happens). Realizing that you should have been more organized only after you gave hundreds of script can be too late since various settings are pointed to the script in it’s current location. Use these simple tips from the start and you could save yourself a lot of headache in the future.
Naming Conventions
Do
Name the files something meaningful. The number of scripts in the silprograms folder will build up over time. It is not recommended to name files something ambiguous like "script1.sil". Once you have dozens of scripts you will not be able to identify what the purpose of the script is. Instead, name the file something meaningful like "userstoryPostFunction.sil".
Use folders. Keeping scripts organized in folders makes finding them later much easier. See below for recommended organization methods.
Use a file extension. While not required it is possible to different types of files in the silprograms folder other than SIL scripts. The recommended file extensions are:
For SIL scripts: .sil
Text files: .txt
CSV data files: .csv
JavaScript files: .js
Use Camel Case. Using camelCase is a good way to keep file names short yet readable.
Don't
Don't add a version number to the "good" or working copy of the script. Adding a version number to the working copy of the script requires you to modify the workflow, listener, etc., to use the script with the latest version. Instead, use version numbers on the old versions of the script. The working copy can have something like "latest" in the name to indicate that it is the most recent version. Example:
userstoryPostFunction_latest.sil
userstoryPostFunction_v1.sil
userstoryPostFunction_v2.sil
userstoryPostFunction_v3.sil
Do not use spaces in the file or folder names. While spaces are allowed it can cause difficulty when using file paths with spaces in them. Spaces can be substituted with underscores.
Folders
Before creating scripts in the SIL manager you should have a general plan on how to organize the files in folders. In general, there are two main schools of thought into organizing files in the SIL Manager:
Organize scripts by script type
Organize scripts by use or by project
Script Type
Most scripts are designed to be applied in a specific way, as part of a workflow for example. By organizing scripts by type it is an easy way to locate the script. This would be preferred way since scripts can be applied multiple projects but are typically applied using a single method.
Example:
Calls
Custom_Fields
Includes
Javascript
JQL
Listeners
Live_Fields
Runner_Gadget
Param_Scripts
Scheduled_Services
Workflows
Conditions
Validators
Postfunctions
Project
You are not limited to a single method. In this example the scripts are organized by project at the highest level then type in the next level of the hierarchy.
Example:
Project_A
Workflows
Conditions
Validators
Postfunctions
Project_B
Listeners
Live_Fields
Project_C