The "feedback loop" is a vital part of any DevOps toolchain. The "feedback loop" is how teams can be proactively notified when changes are happening to infrastructure or code and also when actions need to be taken such as fixing a deployment or test failure. MyST provides a feedback loop through it's sophisticated support for event notifications.
MyST supports two types of notifications
MyST has a default email notification mechanism. When enabled, MyST users will receive notifications for significant events such as when they are required to approval or perform an Application Release.
To configure via the fc-configuration.properties, update /usr/local/tomcat/conf/fusioncloud/fc-configuration.properties
with the following.
smtp.user.name=<email>
smtp.password=<password>
smtp.host=smtp.gmail.com
smtp.port=587
Once MyST is restarted, the password in the file will be automatically encrypted and the Email notification sender will be configured. If the configuration details are incorrect, you will see a related exception in the MyST log.
MyST provides an API for establishing the one-time email notification configuration. To interact with the MyST REST API, an API key must first be obtained.
Set MYST_TOKEN
as an environment variable containing the MyST Studio API Key and MYST_HOST
as an environment variable containing the MyST host.
Run the following
MYST_HOST=<YOUR_MYST_HOST>
MYST_TOKEN=<YOUR_MYST_API_TOKEN>
curl -k https://${MYST_HOST}/api/v1/administration/configuration/properties \
-H "Authorization: Bearer ${MYST_TOKEN}" \
-H 'Content-Type: application/json'
This should output something similar to the following:
{
"data": {
"fc.host.address": "localhost",
"fc.quiet_period_sec.platform_instance": "15",
"fc.quiet_period_sec.release_pipeline": "60",
"fc.port": "8085",
"fc.oauth.endpoint": "http://localhost:8080/security"
},
"meta": {
"status": "SUCCESS",
"code": "0",
"timeStamp": "2018-07-06 03:44:15.019 +0000"
}
}
MYST_HOST=<YOUR_MYST_HOST>
MYST_TOKEN=<YOUR_MYST_API_TOKEN>
curl -X PATCH -k https://${MYST_HOST}/api/v1/administration/configuration/properties \
-H "Authorization: Bearer ${MYST_TOKEN}" \
-H 'Content-Type: application/json' \
-d '{
"smtp.user.name": "<email>",
"smtp.password": "<password>",
"smtp.host": "smtp.gmail.com",
"smtp.port": "587"
}'
MyST Custom Actions provide a simple but powerful event notification mechanism.
Below are some examples of custom notifications that can be achieved in MyST:
Although MyST Custom Actions can be great for triggering notifications at various stages in a platform or application lifecycle, it should be noted that they can be really used for any action. Basically, a custom action allows for to say
When MyST does X, I want it to also do Y...
When using a MyST Custom Action for the purpose of notifications, we write a small function in Python, Java or Jython (i.e. Python which runs in the JVM and has access to Java libraries).
MyST allows for the execution of Custom Actions in the event of a failure or success of a Core MyST Action. This can be a useful way to establish notification to other services such as Email and Slack.
Below is a working example of establishing slack notifications from MyST. Before working through these steps, please make sure you are on version 5.8.6 or later.
Be sure to replace the hardcoded channel below with the actual identifier.
import os
def myst(cfg):
action_name=cfg.configuration.getRequest().getAction()
message = action_name.capitalize() + " success on " + cfg['internal.admin.url']
os.system("curl -X POST -H 'Authorization: Bearer "+ cfg['slack.token.password'] +"' -H 'Content-type: application/json' --data '{\"channel\":\"G8F3FN40J\",\"text\":\""+message+"\",\"username\":\"MyST slack bot\"}' https://slack.com/api/chat.postMessage")
import os
def myst(cfg):
action_name=cfg.configuration.getRequest().getAction()
message = "ERROR: " + action_name.capitalize() + " failed on " + cfg['internal.admin.url']
os.system("curl -X POST -H 'Authorization: Bearer " + cfg['slack.token.password'] + "' -H 'Content-type: application/json' --data '{\"channel\":\"G8F3FN40J\",\"text\":\""+message+"\",\"username\":\"MyST slack bot\"}' https://slack.com/api/chat.postMessage")