Skip to content

Commit a6733a2

Browse files
Added examples of subscription with email notification . (#431)
* Documentation now has examples of subscriptions with email notification
1 parent 7b7e984 commit a6733a2

File tree

1 file changed

+105
-6
lines changed

1 file changed

+105
-6
lines changed

wiki/subscription-with-email-notification.md

Lines changed: 105 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -36,13 +36,40 @@ subject which is configured in Eiffel Intelligence application.properties. Not r
3636
If any authentication is needed by Eiffel Intelligence to send the notification email.
3737

3838
## notificationMessageKeyValues
39-
Content of the email message. The form key should always be an empty string
40-
for email messages. Only one key/value pair is allowed for email message body,
41-
since only the first value will be used.
4239

43-
The form value will be run through JMESPath engine so it is possible to use
44-
JMESPath expressions to extract content from the aggregated object. The
45-
form value can only be one JSON object.
40+
Below are the limitations of notificationMessageKeyValues.
41+
42+
### Limitations
43+
44+
* The form key should always be an empty string.
45+
* The content should be in JSON format.
46+
* The form value can only be one JSON object is allowed (not several objects on the same level).
47+
* Only one key/value pair is allowed (since only the first value will be used).
48+
* It is possible to make use of the data inside the aggregation, using the "@" symbol.
49+
* As with the conditions, it is also possible to write JMESPath expressions.
50+
51+
In the below example the full aggregation can be sent using the '@' character.
52+
53+
"notificationMessageKeyValues": [
54+
{
55+
"formkey": "",
56+
"formvalue": "@"
57+
}
58+
]
59+
60+
To access parts of the aggregation it is possible to define like the below example:
61+
62+
"notificationMessageKeyValues": [{
63+
"formkey": "",
64+
"formvalue": "{parameters: [{ name: 'jsonparams', value : to_string(@) }, { name: 'artifactIdentity', value : @.identity }]}"
65+
}]
66+
67+
The key is 'jsonparams' and the value is the full aggregated object. The second parameter is the artifact identity which is extracted from the aggregation, These are part of the notification message for this particular subscription. Below is a list of the parameters defined in the above notification message which will be sent for the subscription.
68+
69+
parameters:
70+
jsonparams: //full aggregated object
71+
artifactIdentity: //extract the identity string from the aggregation
72+
4673

4774
## requirements
4875
An array of one or several requirements. At least one requirement should be
@@ -83,6 +110,78 @@ be fulfilled.
83110
]
84111
}
85112

113+
Additional examples of how to write subscription with email notification:
114+
115+
The below subscription to trigger a notification an aggregation should contain an artifact with a given identity.
116+
117+
{
118+
"subscriptionName" : "Subscription_with_Mail_Notification",
119+
"ldapUserName" : "ABC",
120+
"repeat" : false,
121+
"created" : 1580287633704,
122+
123+
"notificationType" : "MAIL",
124+
"notificationMeta" : "mymail@company.com, another@email.com",
125+
"emailSubject" : "My Email Subject",
126+
127+
"authenticationType" : "NO_AUTH",
128+
129+
"notificationMessageKeyValues" : [
130+
{
131+
"formkey" : "",
132+
"formvalue" : "{parameters: [{ name: 'artifactIdentity', value : to_string(@.identity) }, { name: 'testCase', value: to_string(@.testCaseExecutions[0].testCase.id) }]}"
133+
}
134+
],
135+
"requirements" : [
136+
{
137+
"conditions" : [
138+
{
139+
"jmespath" : "identity=='pkg:maven/com.othercompany.library/artifact-name@1.0.0'"
140+
}
141+
]
142+
}
143+
]
144+
}
145+
146+
The JMESPath expression in the subscription notification selects the field identity from the aggregated object and this is used as value for the parameter "artifactIdentity". The second parameter is also extracted from the aggregation and results in a string value of the testcase id. The complete notification message can be seen below:
147+
148+
parameters:
149+
artifactIdentity: //extract the identity string from the aggregation
150+
testCase: //extract the testCaseId string from the aggregation
151+
152+
The below subscription will perform a MAIL notification when an artifact identity should contain a given artifact namespace.
153+
154+
{
155+
"subscriptionName" : "Subscription_with_Mail_Notification",
156+
"ldapUserName" : "ABC",
157+
"repeat" : false,
158+
"created" : 1580287633708,
159+
160+
"notificationType" : "MAIL",
161+
"notificationMeta" : "mymail@company.com, another@email.com",
162+
"emailSubject" : "My Email Subject",
163+
164+
"authenticationType" : "NO_AUTH",
165+
166+
"notificationMessageKeyValues" : [
167+
{
168+
"formkey" : "",
169+
"formvalue" : "@"
170+
}
171+
],
172+
"requirements" : [
173+
{
174+
"conditions" : [
175+
{
176+
"jmespath" : "split(identity, '/') | [1] =='com.othercompany.library'"
177+
}
178+
]
179+
}
180+
]
181+
}
182+
183+
The above example mail notififcation message is the full aggregated object.
184+
86185
## Enabling E-mail Notification for Eiffel Intelligence
87186

88187
In order to use subscriptions with e-mail notifications, Eiffel Intelligence

0 commit comments

Comments
 (0)