When the desired Eiffel events have been aggregated a user would like to be notified and there is possibility to register a subscription that will be run on each save of an aggregated object in the database.
Whenever an aggregated object is created or modified, it is evaluated against all registered subscriptions to find out whether the aggregated object meets any subscription requirements. If it fulfills a subscription requirement then a notification is sent to the subscriber as specified in that subscription. For further explanation of the process, consider the following example.
It is possible to add subscriptions using the Eiffel Intelligence front-end GUI. It is also possible to manage subscriptions using the REST API.
It is possible for users to add comments, at any level, in subscriptions. These comments should be a new field in the given subscription, following the json format.
{
"description": "It is my comment"
}
Today Eiffel Intelligence supports notifications by email or by sending a HTTP POST request. It is also possible to pass parameters with the HTTP request. Example subscriptions with different types of notification can be found in the below links:
- Subscription with HTTP POST notification
- Subscription with HTTP POST notification to trigger parameterized Jenkins job
- Subscription with E-mail notification
When writing subscription requirements, they are referencing the structure of the aggregated object which Eiffel Intelligence will create based on the rules it was configured with. It is therefore important to know what the aggregated object will look like when writing the conditions.
In order for a subscription to be triggered, the subscription requirement needs to be fulfilled. The requirements can be grouped with one or several conditions inside them. Each requirement group is separated with an 'OR', while the conditions inside a requirement are connected with an 'AND'. This means all the conditions in a requirement group must be fulfilled, while only one of the requirement groups needs to be fulfilled, for the subscription to trigger. Subscription templates can be found here.
We will go through how to write some example requirements in subscriptions based on the below aggregated object. Conditions in subscriptions are written with JMESPath syntax. Below is a document containing an aggregated object. In addition to the extracted content from Eiffel events, Eiffel Intelligence has added an extra _id key with the value of the start event. This _id serves as an index in mongo DB and speeds up searches.
{
"_id" : "df4cdb42-1580-4cff-b97a-4d0faa9b2b22",
"fileInformation" : [
{
"extension" : "war",
"classifier" : ""
}
],
"artifactCustomData" : [],
"buildCommand" : "trigger",
"identity" : "pkg:maven/com.mycompany.myproduct/[email protected]",
"confidenceLevels" : [
{
"eventId" : "e3be0cf8-2ebd-4d6d-bf5c-a3b535cd084e",
"name" : "dummy_1_stable",
"time" : 1521452400324,
"value" : "SUCCESS"
}
],
"TemplateName" : "ARTIFACT_1",
"id" : "df4cdb42-1580-4cff-b97a-4d0faa9b2b22",
"time" : 1521452368194,
"type" : "EiffelArtifactCreatedEvent",
"publications" : [
{
"eventId" : "2acd348d-05e6-4945-b441-dc7c1e55534e",
"locations" : [
{
"type" : "NEXUS",
"uri" : "http://host:port/path"
}
],
"time" : 1521452368758
}
]
}
Let's say we need a subscription which is triggered on when an artifact has been published to a location of type "NEXUS". This subscription wants to listen for when an Eiffel ArtifactPublished event is aggregated by Eiffel Intelligence.
It is possible to use JMESPath expressions in the conditions of a subscription. We can write a requirement in the subscription with the condition to check for the data of interest. In this case, it is a JSON object in the list of locations containing the key "type" and value "NEXUS". This could be expressed like below:
publications[?locations[?type=='NEXUS']]
It is important to note, when writing conditions the expression starts inside the aggregated object. This means we only have to traverse the JSON structure inside the aggregated object.
If we want to trigger a subscription based on when an artifact has reached the confidence level of 'SUCCESS' we can write the below expression for our condition:
confidenceLevels[?name=='dummy_1_stable'] && confidenceLevels[?value=='SUCCESS']
These two conditions check both that the artifact name is the right one, and that the confidence level is what we are looking for.
See in the frontend documentation here