@@ -6,12 +6,12 @@ and [adding subscriptions via Eiffel Intelligence frontend GUI](https://github.c
6
6
7
7
{
8
8
"created": "2017-07-26",
9
- "notificationMeta": "http://127.0.0.1:3000/ei/test_subscription_rest ",
9
+ "notificationMeta": "http://127.0.0.1:3000/api/send ",
10
10
"notificationType": "REST_POST",
11
11
"restPostBodyMediaType": "application/x-www-form-urlencoded",
12
12
"notificationMessageKeyValues": [{
13
- "formkey": "e ",
14
- "formvalue": "{parameter : [{ name: 'jsonparams', value : to_string(@) }, { name: 'runpipeline ', value : 'mybuildstep' }]}"
13
+ "formkey": "data ",
14
+ "formvalue": "{parameters : [{ name: 'jsonparams', value : to_string(@) }, { name: 'artifact_identity ', value : @.identity }]}"
15
15
}],
16
16
"repeat": false,
17
17
"requirements": [{
@@ -22,7 +22,6 @@ and [adding subscriptions via Eiffel Intelligence frontend GUI](https://github.c
22
22
"jmespath": "testCaseExecutions[?testCase.conclusion == 'SUCCESSFUL' && testCase.id=='TC5']"
23
23
}
24
24
],
25
- "type": "ARTIFACT_1"
26
25
},
27
26
{
28
27
"conditions": [{
@@ -32,18 +31,16 @@ and [adding subscriptions via Eiffel Intelligence frontend GUI](https://github.c
32
31
"jmespath": "testCaseExecutions[?testCaseStartedEventId == '13af4a14-f951-4346-a1ba-624c79f10e98']"
33
32
}
34
33
],
35
- "type": "ARTIFACT_1"
36
34
}
37
35
],
38
36
"subscriptionName": "Subscription_Test",
39
37
"userName": "ABC"
40
38
}
41
39
42
-
43
40
In this subscription, two requirements are given, where each requirement in turn
44
41
contains two conditions. As per subscription logic, when all the conditions in
45
42
any one of the given requirements are met in an aggregated object then the
46
- subscription is triggered. Triggering means that the subscriber will be notified
43
+ subscription is fulfilled. This means that the subscriber will be notified
47
44
with the chosen notification method. It should be noted that conditions are given
48
45
as JMESPath expression. Let us suppose that an aggregated object, as shown below,
49
46
is created:
@@ -73,11 +70,10 @@ is created:
73
70
"identity": "pkg:maven/com.mycompany.myproduct/sub-system@1.1.0"
74
71
}
75
72
76
-
77
73
When this aggregated object is evaluated against the subscriptions stored in
78
- database, then it fulfills our subscription criteria. It can be seen that both
79
- conditions of the first requirement are satisfied by the aggregated object.
80
- More specifically, in the first condition, JMESPath rule is looking for:
74
+ the database, then it fulfills our subscription criteria. It can be seen
75
+ that both conditions of the first requirement are satisfied by this aggregated
76
+ object. More specifically, in the first condition, JMESPath rule is looking for:
81
77
82
78
identity=='pkg:maven/com.mycompany.myproduct/sub-system@1.1.0'
83
79
@@ -86,28 +82,32 @@ and in the second condition it looks for
86
82
testCaseExecutions.testCase.conclusion == 'SUCCESSFUL' && testCase.id=='TC5'
87
83
88
84
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.
85
+ is started to send notification to the specified subscriber. For this,
86
+ 'notificationMeta' and 'notificationType' field values are extracted from
87
+ the subscription.
91
88
92
89
## Notify via REST POST
93
- In the example subscription above, the notification is sent as ** REST POST** to
94
- the url http://127.0.0.1:3000/ei/test_subscription_rest . The notification message
95
- in this subscription is prepared as key value pairs in the request.
90
+ In the example subscription above, the notification is sent as ** REST POST**
91
+ to the url ` http://127.0.0.1:3000/ei/test_subscription_rest ` . The notification
92
+ message in this subscription is prepared as key value pairs in the request body .
96
93
97
94
"notificationMessageKeyValues": [{
98
- "formkey": "e ",
99
- "formvalue": "{parameter : [{ name: 'jsonparams', value : to_string(@) }, { name: 'runpipeline ', value : 'mybuildstep' }]}"
95
+ "formkey": "data ",
96
+ "formvalue": "{parameters : [{ name: 'jsonparams', value : to_string(@) }, { name: 'artifact_identity ', value : @.identity }]}"
100
97
}]
101
98
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.
99
+ The key is 'jsonparams' and the value is the full aggregated object. The
100
+ second parameter is the artifact identity which is extracted from the
101
+ aggregation, These are part of the notification message for this particular
102
+ subscription. Below is a list of the parameters defined in the above notification
103
+ message which will be sent for this subscription.
105
104
106
105
parameters:
107
- jsonparameters : {full aggregated object}
108
- runpipeline: mybuildstep
106
+ jsonparams : {full aggregated object}
107
+ artifact_identity: pkg:maven/com.mycompany.myproduct/sub-system@1.1.0
109
108
110
- If it was sent as raw JSON body, the notification message would look like below:
109
+ If it was sent as raw JSON body, the first parameter of the notification
110
+ message would look like below:
111
111
112
112
{
113
113
[
@@ -149,40 +149,39 @@ also be set for individual subscriptions using the Eiffel Intelligence front-end
149
149
150
150
As with the conditions, it is also possible to write JMESPath expressions
151
151
for the notification message. If we use the example subscription above, the
152
- notification could be to send parameters which contains only some of the
153
- information from the aggregated object. We could for example use the below
154
- JMESPath expression in the subscription notification message:
152
+ notification could be to send data extracted from the aggregated object.
153
+ We could for example use the below JMESPath expression in the subscription
154
+ notification message:
155
155
156
- "{parameter : [{ name: 'artifactIdentity', value : to_string(@.identity) }, { name: 'testCase', value: to_string(@.testCaseExecutions[0].testCase.id) } { name: 'runpipeline', value : 'mybuildstep' }]}"
156
+ "{parameters : [{ name: 'artifactIdentity', value : to_string(@.identity) }, { name: 'testCase', value: to_string(@.testCaseExecutions[0].testCase.id) }]}"
157
157
158
- This expression only selects the field identity from the aggregated object
159
- and this is used as value for the parameter "artifactIdentity", and the
160
- complete notification message can be seen below:
158
+ This expression selects the field identity from the aggregated object
159
+ and this is used as value for the parameter "artifactIdentity". The second
160
+ parameter is also extracted from the aggregation and results in a string
161
+ value of the testcase id. The complete notification message can be seen below:
161
162
162
163
parameters:
163
164
artifactIdentity: pkg:maven/com.mycompany.myproduct/sub-system@1.1.0
164
165
testCase: TC5
165
- runpipeline: mybuildstep
166
-
167
166
168
167
## Failed notifications
169
168
170
169
If the notification via REST POST fails, then a fixed number of attempts are
171
170
made to resend successfully. The number of attempts are specified in the
172
171
[ application.properties] ( https://github.com/eiffel-community/eiffel-intelligence/blob/master/src/main/resources/application.properties )
173
172
as “notification.failAttempt”. If message sending attempts fails for the
174
- specified number of time, then a failed notification is prepared and stored
175
- in database. The name of the collection is specified in the application.properties
176
- file as “failed.notification.collection-name”. The message is stored in the database
177
- for a certain duration before being deleted. This time can be configured in
178
- application.properties as “notification.ttl.value”.
173
+ specified number of time, then a failed notification is prepared and stored in
174
+ the database. The name of the collection is specified in the application.properties
175
+ file as “failed.notification.collection-name”. The message is stored in the
176
+ database for a certain duration before being deleted. This time can be
177
+ configured in application.properties as “notification.ttl.value”.
179
178
180
179
** Failed notification in the failed notification database with TTL value:**
181
180
182
181
[
183
182
{
184
183
"subscriptionName": "Sub1",
185
- "aggregatedObject": {},
184
+ "aggregatedObject": { full aggregation at the time of notification attempt },
186
185
"notificationMeta": "http://localhost:9999/some-endpoint",
187
186
"_id": {
188
187
"$oid": "5d807a1d821b960af311fab3"
0 commit comments