com.atlassian.confluence.content.render.xhtml.migration.exceptions.UnknownMacroMigrationException: The macro 'next_previous_links' is unknown.

Sample 0106 - Build Statistics Analyzer

Introduction

This sample demonstrates how to generate notifications from build failure information received from an automated build system and send email notifications to users about such failures. This sample uses wso2event (using REST API) as input and emails as outputs.

The query used in this sample is as follows.

from buildfailStatisticsStream
select userID, timestamp, project, team, userName
insert into outbuildfailStream;

The above query is a simple pass-through query, which selects the necessary attributes to generate the email and sends them to the outbuildfailStream. It then goes through an event formatter, which is used to convert it into a proper email message. The configuration of the event formatter is as follows:

<eventFormatter name="BuildFailureNotificationStreamFormatter"
  statistics="disable" trace="enable" xmlns="http://wso2.org/carbon/eventformatter">
  <from streamName="outputBuildFailStatisticsStream" version="1.0.0"/>
  <mapping customMapping="enable" type="text">
    <inline>There is a build failure in the Project - {{project}} of the Team - {{team}} at {{timestamp}}
Details of the build Failure : 
Person ID who responsible for build failure - {{userID}}
Name of the person who responsible for build failure - {{userName}}</inline>
  </mapping>
  <to eventAdaptorName="emailAdaptor" eventAdaptorType="email">
    <property name="email.address">wso2cep@gmail.com</property>
    <property name="email.subject">BuildFailure</property>
  </to>
</eventFormatter>

The configuration above,

  • Has custom text mappings enabled as <mapping customMapping="enable" type="text">
  • Has the text template that is used to generate the final text specified inside the mapping element
  • Uses brackets '(' and ')' to add attributes inside the text that will be replaced by their values in the runtime
  • Dispatches the text generated here to the emailAdapter specified in the <to> element, along with other information such as email address. The Email Output Adapter that comes with the CEP eventually sends it to the address specified.

Prerequisites

Building the sample

Start the WSO2 CEP server with the sample configuration numbered 0106. For instructions, see Starting sample CEP configurations.

  • Creates <CEP_HOME>/repository/conf/data-bridge/stream-definitions.xml file, which is used to create the stream definitions for the sample.
  • Points the default Axis2 repo to <CEP_HOME>/sample/artifacts/0106 (by default, the Axis2 repo is <CEP_HOME>/repository/deployment/server).

Executing the sample

  1. Open a new terminal, go to <CEP_HOME>/samples/producers/build-failure-rest-api and run the following command to define the stream.

    curl -k --user admin:admin https://localhost:9443/datareceiver/1.0.0/streams/ --data @streamdefn1.json -H "Accept: application/json" -H "Content-type: application/json" -X POST
  2. Send events using the following command. It sends the events that are stored in events1.json file.

    curl -k --user admin:admin https://localhost:9443/datareceiver/1.0.0/stream/buildfail_Statistics/1.3.2/ --data @events1.json -H "Accept: application/json" -H "Content-type: application/json" -X POST
  3. You receive an email as shown in the example below, to the specified email address.

    There is a build failure in the Project - "Complex Event Processor" of the Team - "Data Team" at "120d"
    Details of the build Failure :
    
    Person ID who responsible for build failure - "abc@org1.com"
    Name of the person who responsible for build failure - "abc"
com.atlassian.confluence.content.render.xhtml.migration.exceptions.UnknownMacroMigrationException: The macro 'next_previous_links2' is unknown.