Skip to content

Commit 713c7f2

Browse files
Update subscription templates and documentation (#296)
Update subscription templates and documentation.
1 parent 5e81585 commit 713c7f2

File tree

6 files changed

+132
-84
lines changed

6 files changed

+132
-84
lines changed

src/main/resources/templates/subscriptionsTemplate.json

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
[{
22
"subscriptionName" : "Subscription1",
3-
"userName" : "functionalUser",
4-
"password" : "functionalUserPassword",
53
"ldapUserName" : "ABC",
64
"repeat" : false,
7-
"notificationMessageKeyValuesAuth" : [],
85
"authenticationType" : "BASIC_AUTH",
6+
"userName" : "functionalUser",
7+
"password" : "functionalUserPassword",
98
"created" : 1542117412833,
109
"notificationType" : "REST_POST",
1110
"notificationMeta" : "http://eiffel-jenkins1:8080/job/ei-artifact-triggered-job/build",
@@ -32,11 +31,10 @@
3231
"subscriptionName" : "Subscription2",
3332
"ldapUserName" : "ABC",
3433
"repeat" : false,
35-
"notificationMessageKeyValuesAuth" : [],
3634
"authenticationType" : "NO_AUTH",
3735
"created" : 1542117412834,
38-
"notificationMeta" : "http://eiffel-jenkins2:8080/job/ei-artifact-triggered-job/build",
3936
"notificationType" : "REST_POST",
37+
"notificationMeta" : "http://eiffel-jenkins2:8080/job/ei-artifact-triggered-job/build",
4038
"restPostBodyMediaType" : "application/x-www-form-urlencoded",
4139
"notificationMessageKeyValues" : [
4240
{
@@ -54,19 +52,16 @@
5452
}
5553

5654
]
57-
5855
},
5956
{
6057
"subscriptionName" : "Subscription3_Mail_Notification",
6158
"ldapUserName" : "ABC",
6259
"repeat" : false,
63-
"notificationMessageKeyValuesAuth" : [],
6460
"authenticationType" : "NO_AUTH",
6561
"created" : 1542802953782,
62+
"notificationType" : "MAIL",
6663
"notificationMeta" : "mymail@company.com",
6764
"emailSubject" : "My Email Subject",
68-
"notificationType" : "MAIL",
69-
"restPostBodyMediaType" : "",
7065
"notificationMessageKeyValues" : [
7166
{
7267
"formkey" : "",

wiki/markdown/configuration.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -125,12 +125,12 @@ collection is defined by the below property:
125125
**email.sender** defines who should be the sender of the email Eiffel
126126
Intelligence sends when a subscription is triggered. If a subscription is
127127
defined with the notificationMeta "receivermail@example.com" this receiver
128-
would be notified when the subscription fulfills all conditions via an E-mail.
128+
would be notified when the subscription fulfills all conditions via an e-mail.
129129
The sender of this e-mail is defined by the **email.sender** property.
130-
The value for email.subject is used by all subscriptions which have been
130+
The value for "email.subject" is used by all subscriptions which have been
131131
created via the REST API. When a subscription is created using the Eiffel
132-
Intelligence front-end GUI it is possible to set individual email subject
133-
for each subscription.
132+
Intelligence front-end GUI it is possible to set individual e-mail subject
133+
for each subscription. Note that these two properties are mandatory to set.
134134

135135
* email.sender
136136
* email.subject

wiki/markdown/step-by-step-subscription-notification.md

Lines changed: 23 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -77,19 +77,31 @@ is created:
7777
When this aggregated object is evaluated against the subscriptions stored in
7878
database, then it fulfills our subscription criteria. It can be seen that both
7979
conditions of the first requirement are satisfied by the aggregated object.
80-
More specifically, in the first condition, JMESPath rule is looking for
81-
identity=='pkg:maven/com.mycompany.myproduct/sub-system@1.1.0' and in the second
82-
condition it looks for testCaseExecutions.testCase.conclusion == 'SUCCESSFUL'
83-
and testCase.id=='TC5'. Both strings can be found in the aggregated object JSON.
84-
Consequently, the process is started to send notification to specified subscriber.
85-
For this, 'notificationMeta' and 'notificationType' field values are extracted
86-
from the subscription.
80+
More specifically, in the first condition, JMESPath rule is looking for:
81+
82+
identity=='pkg:maven/com.mycompany.myproduct/sub-system@1.1.0'
83+
84+
and in the second condition it looks for
85+
86+
testCaseExecutions.testCase.conclusion == 'SUCCESSFUL' && testCase.id=='TC5'
87+
88+
Both strings can be found in the aggregated object JSON. Consequently, the process
89+
is started to send notification to specified subscriber. For this, 'notificationMeta'
90+
and 'notificationType' field values are extracted from the subscription.
8791

8892
## Notify via REST POST
8993
In the example subscription above, the notification is sent as **REST POST** to
9094
the url http://127.0.0.1:3000/ei/test_subscription_rest. The notification message
91-
is prepared as key value pairs in the request. The notification message in
92-
this example contains the full aggregated object as a value.
95+
in this subscription is prepared as key value pairs in the request.
96+
97+
"notificationMessageKeyValues": [{
98+
"formkey": "e",
99+
"formvalue": "{parameter: [{ name: 'jsonparams', value : to_string(@) }, { name: 'runpipeline', value : 'mybuildstep' }]}"
100+
}]
101+
102+
The key is 'jsonparams' and the value is the full aggregated object. These are part
103+
of the notification message for this particular subscription. Below is a list of the
104+
key value pairs which will be sent for this subscription.
93105

94106
parameters:
95107
jsonparameters: {full aggregated object}
@@ -163,8 +175,8 @@ specified number of time, then a missed notification is prepared and stored
163175
in database. The name of the database is specified in the application.properties
164176
file as “missedNotificationDataBaseName” and collection name as
165177
“missedNotificationCollectionName”. The message is stored in the database
166-
for a certain duration before being deleted. This time can be configured in the
167-
property file as “notification.ttl.value”.
178+
for a certain duration before being deleted. This time can be configured in
179+
application.properties as “notification.ttl.value”.
168180

169181
**Missed notification in the missed notification database with TTL value:**
170182

wiki/markdown/subscription-with-REST-POST-notification.md

Lines changed: 27 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -10,40 +10,45 @@ contains comments like below.**_
1010
_**Subscription templates can be found [here](https://github.com/Ericsson/eiffel-intelligence/tree/master/src/main/resources/templates).**_
1111

1212
{
13+
// The name of the subscription to make it easy to search for it.
14+
// Only numbers, letters and underscore allowed.
1315
"subscriptionName" : "Subscription1",
1416

15-
// the name of the user who created the subscription
16-
// defaults to an empty string if LDAP is disabled
17+
// The name of the logged in user creating or updating the subscription
18+
// added by Eiffel Intelligence if LDAP is enabled. Defaults to an empty string.
1719
"ldapUserName" : "ABC",
1820

19-
// instructs whether same subscription should be re-triggered for new additions
20-
// to the aggregated object. If false only first time the conditions are fulfilled
21-
// a notification will be triggered. No matter how many times the aggregated object
22-
// is updated.
21+
// Instructs whether the same subscription should be re-triggered
22+
// for new additions to the aggregated object. If this is set to
23+
// false, only the first time the conditions are fulfilled, a
24+
// notification will be triggered. No matter how many times the
25+
// aggregated object is updated.
2326
"repeat" : false,
24-
"notificationMessageKeyValuesAuth" : [],
27+
28+
// Creation time in system time, added by Eiffel Intelligence.
2529
"created" : 1542117412833,
2630

27-
// how to notify when a subscription is triggered
28-
"notificationType" : "REST_POST",
2931
"authenticationType" : "BASIC_AUTH",
3032

31-
// the username and password to insert in headers of the POST request when sending
32-
// a notification via REST POST
33+
// The username and password to insert in headers of the POST request when sending
34+
// a notification via REST POST.
3335
"userName" : "functionalUser",
3436
"password" : "functionalUserPassword",
3537

36-
// which url to use for the HTTP POST request
38+
// How to notify when a subscription is triggered.
39+
"notificationType" : "REST_POST",
40+
41+
// Which url to use for the HTTP POST request.
3742
"notificationMeta" : "http://eiffel-jenkins1:8080/job/ei-artifact-triggered-job/build",
3843

39-
// headers for the HTTP request, can be 'application/x-www-form-urlencoded' or 'application/json'
44+
// Headers for the HTTP request, can be 'application/x-www-form-urlencoded' or 'application/json'.
4045
"restPostBodyMediaType" : "application/json",
4146

42-
// the data to send with the HTTP POST request
47+
// The data to send with the HTTP POST request.
4348
"notificationMessageKeyValues" : [
4449
{
45-
// form value will be run through JMESPATH engine to extract
46-
// content from aggregated object.
50+
// The form value will be run through JMESPATH engine to extract
51+
// content from the aggregated object.
4752

4853
"formkey" : "json",
4954
"formvalue" : "{parameter: [{ name: 'jsonparams', value : to_string(@) }]}"
@@ -67,3 +72,9 @@ _**Subscription templates can be found [here](https://github.com/Ericsson/eiffel
6772

6873
]
6974
}
75+
76+
77+
## Requirements and conditions
78+
79+
Read more on how Eiffel Intelligence groups [requirements and conditions in subscriptions](https://github.com/eiffel-community/eiffel-intelligence/blob/master/wiki/markdown/subscriptions.md#writing-requirements-and-conditions).
80+

wiki/markdown/subscription-with-email-notification.md

Lines changed: 31 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -10,42 +10,42 @@ contains comments like below.**_
1010
_**Subscription templates can be found [here](https://github.com/Ericsson/eiffel-intelligence/tree/master/src/main/resources/templates).**_
1111

1212
{
13-
// the name of the subscription to make it easy to search for it
14-
// Only numbers,letters and underscore allowed
13+
// The name of the subscription to make it easy to search for it.
14+
// Only numbers, letters and underscore allowed.
1515
"subscriptionName" : "Subscription3_Mail_Notification",
1616

17-
// the name of the logged in user creating or updating the subscription
18-
// added by Eiffel Intelligence if LDAP is enabled, defaults to an empty string
17+
// The name of the logged in user creating or updating the subscription
18+
// added by Eiffel Intelligence if LDAP is enabled. Defaults to an empty string.
1919
"ldapUserName" : "ABC",
2020

21-
// instructs whether same subscription should be re-triggered for new additions
21+
// Instructs whether same subscription should be re-triggered for new additions
2222
// to the aggregated object. If false only first time the conditions are fulfilled
2323
// a notification will be triggered. No matter how many times the aggregated object
2424
// is updated.
2525
"repeat" : false,
26-
"notificationMessageKeyValuesAuth" : [],
27-
"authenticationType" : "NO_AUTH",
28-
29-
// creation time in system time. added by Eiffel Intelligence
26+
27+
// Creation time in system time, added by Eiffel Intelligence.
3028
"created" : 1542802953782,
31-
32-
// how to notify the user
29+
30+
"authenticationType" : "NO_AUTH",
31+
32+
// How to notify when a subscription is triggered.
3333
"notificationType" : "MAIL",
3434
"notificationMeta" : "mymail@company.com",
3535
"emailSubject" : "My Email Subject",
36-
"restPostBodyMediaType" : "",
37-
38-
// content of the email message
36+
37+
// Content of the email message.
3938
"notificationMessageKeyValues" : [
4039
{
41-
// form key should always be an empty string for email messages.
42-
// form value will be run through JMESPATH engine to extract
40+
// Form key should always be an empty string for email messages.
41+
// Form value will be run through JMESPATH engine to extract
4342
// content from aggregated object.
4443

4544
"formkey" : "",
4645
"formvalue" : "{mydata: [{ fullaggregation : to_string(@) }]}"
4746
}
4847
],
48+
4949
// An array of requirements. At least one requirement should be fulfilled to
5050
// trigger this subscription.
5151
"requirements" : [
@@ -63,3 +63,18 @@ _**Subscription templates can be found [here](https://github.com/Ericsson/eiffel
6363
]
6464
}
6565

66+
## Enabling e-mail notification for Eiffel Intelligence
67+
68+
In order to use subscriptions with e-mail notifications, Eiffel Intelligence
69+
must be set up with an e-mail server in [application.properties](https://github.com/eiffel-community/eiffel-intelligence/blob/master/src/main/resources/application.properties).
70+
The e-mail subject for a subscription can be set globally or for each individual
71+
subscription. If the field emailSubject is left empty in the subscription, Eiffel
72+
Intelligence will use the default one.
73+
74+
## Requirements and conditions
75+
76+
Read more on how Eiffel Intelligence groups [requirements and conditions in subscriptions](https://github.com/eiffel-community/eiffel-intelligence/blob/master/wiki/markdown/subscriptions.md#writing-requirements-and-conditions).
77+
78+
79+
80+

wiki/markdown/triggering-jenkins-jobs.md

Lines changed: 43 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -10,40 +10,46 @@ There are some important details to know when triggering Jenkins jobs with param
1010
* the parameters need to be send in the URL
1111
* do not specify more parameters than you have in your job. This is a Jenkins security feature to hinder that someone triggers jobs that overwrite job environment variables. Your job will not be triggered otherwise.
1212

13-
Example below shows a subscription that triggers a parameterized Jenkins job having job token and a parameter object containing the aggregated object.
14-
Observe that we use buildWithParameters and empty notificationMessageKeyValues.
13+
Example below shows a subscription that triggers a parameterized Jenkins job having job token and a parameter object containing the aggregated object.
14+
Observe that we use buildWithParameters and empty notificationMessageKeyValues.
1515

1616
{
17+
// The name of the subscription to make it easy to search for it.
18+
// Only numbers,letters and underscore allowed.
1719
"subscriptionName" : "Subscription1",
1820

19-
// the name of the user who created the subscription
20-
// defaults to an empty string if LDAP is disabled
21+
// The name of the logged in user creating or updating the subscription
22+
// added by Eiffel Intelligence if LDAP is enabled. Defaults to an empty string.
2123
"ldapUserName" : "ABC",
2224

23-
// instructs whether same subscription should be re-triggered for new additions
24-
// to the aggregated object. If false only first time the conditions are fulfilled
25-
// a notification will be triggered. No matter how many times the aggregated object
26-
// is updated.
25+
// Instructs whether the same subscription should be re-triggered
26+
// for new additions to the aggregated object. If this is set to
27+
// false, only the first time the conditions are fulfilled, a
28+
// notification will be triggered. No matter how many times the
29+
// aggregated object is updated.
2730
"repeat" : false,
28-
"notificationMessageKeyValuesAuth" : [],
31+
32+
// Creation time in system time, added by Eiffel Intelligence.
2933
"created" : 1542117412833,
3034

31-
// how to notify when a subscription is triggered
32-
"notificationType" : "REST_POST",
35+
"notificationMessageKeyValuesAuth" : [],
3336
"authenticationType" : "BASIC_AUTH",
3437

35-
// the username and password to insert in headers of the POST request when sending
36-
// a notification via REST POST
38+
// The username and password to insert in headers of the POST request when sending
39+
// a notification via REST POST.
3740
"userName" : "functionalUser",
3841
"password" : "functionalUserPassword",
3942

40-
// which url to use for the HTTP POST request
43+
// How to notify when a subscription is triggered.
44+
"notificationType" : "REST_POST",
45+
46+
// Which url to use for the HTTP POST request.
4147
"notificationMeta" : "http://eiffel-jenkins1:8080/job/ei-artifact-triggered-job/buildWithParameters?token='TOKEN'&object=id",
4248

43-
// headers for the HTTP request, can be 'application/x-www-form-urlencoded' or 'application/json'
49+
// Headers for the HTTP request, can be 'application/x-www-form-urlencoded' or 'application/json'.
4450
"restPostBodyMediaType" : "application/json",
4551

46-
// the data to send with the HTTP POST request
52+
// The data to send with the HTTP POST request.
4753
"notificationMessageKeyValues" : [
4854
{
4955
}
@@ -74,39 +80,43 @@ There are some important details to know when triggering Jenkins jobs with param
7480
The subscription below triggers the same parameterized Jenkins job but we now use build endpoint and we send the parameter in a json form using REST body.
7581

7682
{
83+
// The name of the subscription to make it easy to search for it.
84+
// Only numbers, letters and underscore allowed.
7785
"subscriptionName" : "Subscription1",
7886

79-
// the name of the user who created the subscription
80-
// defaults to an empty string if LDAP is disabled
87+
// The name of the logged in user creating or updating the subscription
88+
// added by Eiffel Intelligence if LDAP is enabled. Defaults to an empty string.
8189
"ldapUserName" : "ABC",
8290

83-
// instructs whether same subscription should be re-triggered for new additions
91+
// Instructs whether same subscription should be re-triggered for new additions
8492
// to the aggregated object. If false only first time the conditions are fulfilled
8593
// a notification will be triggered. No matter how many times the aggregated object
8694
// is updated.
8795
"repeat" : false,
88-
"notificationMessageKeyValuesAuth" : [],
96+
97+
// Creation time in system time, added by Eiffel Intelligence.
8998
"created" : 1542117412833,
9099

91-
// how to notify when a subscription is triggered
92-
"notificationType" : "REST_POST",
93100
"authenticationType" : "BASIC_AUTH",
94101

95-
// the username and password to insert in headers of the POST request when sending
96-
// a notification via REST POST
102+
// How to notify when a subscription is triggered.
103+
"notificationType" : "REST_POST",
104+
105+
// The username and password to insert in headers of the POST request when sending
106+
// a notification via REST POST.
97107
"userName" : "functionalUser",
98108
"password" : "functionalUserPassword",
99109

100-
// which url to use for the HTTP POST request
110+
// Which url to use for the HTTP POST request.
101111
"notificationMeta" : "http://eiffel-jenkins1:8080/job/ei-artifact-triggered-job/build?token='TOKEN'",
102112

103-
// headers for the HTTP request, can be 'application/x-www-form-urlencoded' or 'application/json'
113+
// Headers for the HTTP request, can be 'application/x-www-form-urlencoded' or 'application/json'.
104114
"restPostBodyMediaType" : "application/json",
105115

106-
// the data to send with the HTTP POST request
116+
// The data to send with the HTTP POST request.
107117
"notificationMessageKeyValues" : [
108118
{
109-
// form value will be run through JMESPATH engine to extract
119+
// The form value will be run through JMESPATH engine to extract
110120
// content from aggregated object.
111121

112122
"formkey" : "json",
@@ -131,3 +141,8 @@ There are some important details to know when triggering Jenkins jobs with param
131141

132142
]
133143
}
144+
145+
## Requirements and conditions
146+
147+
Read more on how Eiffel Intelligence groups [requirements and conditions in subscriptions](https://github.com/eiffel-community/eiffel-intelligence/blob/master/wiki/markdown/subscriptions.md#writing-requirements-and-conditions).
148+

0 commit comments

Comments
 (0)