Technology Blogs by SAP
Learn how to extend and personalize SAP applications. Follow the SAP technology blog for insights into SAP BTP, ABAP, SAP Analytics Cloud, SAP HANA, and more.
cancel
Showing results for 
Search instead for 
Did you mean: 
BiserSimeonov
Product and Topic Expert
Product and Topic Expert
Hello SAP community! I would like to share with you insights on how easy is to configure SAP Alert Notification service on SAP BTP in a way so that you can get instant notifications for potential disruptions in your system and more specifically – failed builds on  SAP Continuous Integration and Delivery.

This blog-post is also an extension to What’s going on in your CI/CD pipeline?  created by christoph.szymanski so also credits to Christoph for the initial setup.

Context


To be frank, I was inspired to write also this blog-post as the integration between Alert Notification service and SAP Continuous Integration and Delivery indeed is quite intuitive. All you need to do is to create the needed credentials, enable a toggle button available in SAP Continuous Integration and D and configure the needed alerts! If you are interested  to learn more about it - all details are provided underneath.

Alerting for failed builds on SAP Continuous Integration and Delivery via SAP Alert Notification service


Solution diagram



The main concept for this use case is setting up a reliable and instant alerting in SAP Business Technology Platform (SAP BTP) for sending instant notifications in case a build in SAP Continuous Integration and Delivery  has been failed. To meet these expectations I have implemented SAP Alert Notification service in a way so that in case there is a failed job - an instant notification is sent out to the responsible DevOps / SRE team.

Implementation


Create a Service Key credentials in Alert Notification service


As a first step you need to authenticate your  SAP Continuous Integration and Delivery pipeline to the SAP Alert Notification service. To do so, you need to create a Service Key credentials for the

Alert Notification service as shown below:

1. Go Alert Notification service instance in your SAP BTP account, navigate the to the "Service Keys" section and click on the "Create" button.


 

2. Specify the "Service Key Name" (free text) and click on the "Create" button.


3. You will see that the service key creation has been started.


4. Once the service key has been created, please view and copied it over as a JSON format:




Create credentials in SAP Continuous Integration and Delivery


1. Navigate to SAP Continuous Integration and Delivery and access the "Credentials" section. Once that's done, please click on the "+" button to provided the needed credentials details:

  • specify the name and the description (free text);

  • specify the credential type - pick up "Service Key" from the drop-down;

  • paste the JSON service key from the Alert Notification service you had already created in the previous step;

  • click on the "Create" button to save the credentials




Enablement of Build Notifications for SAP Continuous Integration and Delivery


Now, after you have created all the needed credentials, you need to enable the notifications so that  SAP Continuous Integration and Delivery can start ingesting notifications to SAP Alert Notification service for the relevant pipeline events . To do so, please follow these steps:

1. Access to the pipeline you want to start monitoring and click on the “Edit” button.


2. Click on the Build Notifications to access the relevant section and enable the notifications for the given pipeline:

  • click on the toggle button to turn it into ON.





  • click on the "Service Key" and pick up the credentials for the Alert Notification service you already have created in the previous step:




 

 





  • Click on the "Save" button to save the changes made:










Your pipeline is configured to send notifications to the Alert Notification service.

Configuring the Alert Notification service


Now it is time to configure the Alert Notification service itself and see it in actions.

In order to be able filter and act on the events ingested into the Alert Notification service it is needed to create:

  • Conditions: needed to filter out the events which are important for you;

  • Actions: specify actions to be triggered by the Alert Notification service, e.g. send email, send instant notifications (via Microsoft Teams Slack, etc), trigger HTTPS webhooks, trigger automation flow, etc;

  • Subscription – that is the entity that binds one or more conditions to one or more actions that have been already set. Note that without an active subscription no action will be triggered by Alert Notification service.


Setting "Conditions" in Alert Notification service


The configuration of Alert Notification service in this use case is to notify our DevOps team in case of failed CID jobs. There are various of available parameters to be considered when the condition within the Alert Notification service is to be set – you can check out the available event properties here.

Nevertheless, I have decided to go with two conditions:


  • eventType = end



  • body CONTAINS Build has finished with 'FAILURE'





NOTE: Mandatory conditions are those that must always be met within the subscriptions where they are used. For the second condition I have enabled the mandatory condition so that I will receive notification only the ended builds that have been failed.

Setting "Actions" in Alert Notification service


As an action I have created two actions that will be triggered in parallel:



Setting "Subscription" in Alert Notification service


Of course, as already mentioned, it is needed to setup the relevant subscription where I have picked up both conditions and both actions already configured.



End-to-end test and output


As an end result, as expected, in case my pipeline fails, I get an instant notification delivered by the Alert Notification service over email and also in the relevant Microsoft Teams channel. The details included in these notifications are ingested directly from SAP Continuous Integration and Delivery (see below).

Email received




Instant message over Microsoft Teams




Other considerations


SAP Automation Pilot


In addition the described use case (as also shown in the solution diagram) it is also possible Alert Notification service to trigger automatically a remediation action executed by SAP Automation Pilot. This is not covered in the current blog-post but in case you are interested in, please feel free to check out these resources:


SAP Cloud ALM for Operations


Another aspect of this use case is that the Alert Notification service can be integrated further into the SAP Cloud ALM for Operations that provides a central entry point to operate your complete SAP landscape running on different technologies (including SAP BTP).

Feedback / Questions


I hope this blog-post is useful and in case of any questions / comments, please do not hesitate add a comment and / or reach out to me.