Automation rule to add multiple users to multiple groups identified from Jira issue
Platform Notice: Cloud Only - This article only applies to Atlassian products on the cloud platform.
Summary
A customer requested a solution to automatically add multiple users listed in a Jira issue to multiple groups, also specified in the same issue. However, Jira Automation's current branching feature does not support iterating over both users and groups simultaneously. To implement this, two Automation rules were developed to meet the requirements through webhook-based integrations.
Environment
Jira Cloud
Automation: Automation for Jira (A4J)
Custom Fields:
customfield_10104
: Contains the user information.customfield_10108
: Contains the group information.
Diagnosis
Jira Automation allows branching based on smart values for either users or groups, but it does not support nested iterations (branching) for processing multiple users and groups simultaneously.
A workaround was identified using webhooks to retrieve group information and associate it with user account IDs.
Cause
The current limitation in Jira Automation prevents the use of nested branches to process both users and groups simultaneously. This meant that a standard rule couldn't handle the customer's requirement to add multiple users to multiple groups directly.
Solution
Rule 1: To identify the users and group
First, import the Automation rule
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
{
"cloud": true,
"rules": [
{
"id": 21067571,
"clientKey": "466b9777-4c4a-3815-bc3a-43dfc2f50896",
"name": "web Add multi user to group (V4) - modified ",
"state": "DISABLED",
"description": "",
"authorAccountId": "63da235ffb75f8568f5f6e38",
"actor": {
"type": "ACCOUNT_ID",
"value": "557058:f58131cb-b67d-43c7-b30d-6b58d40bd077"
},
"created": 1723475883144,
"updated": 1723537377851,
"trigger": {
"id": "562970758",
"component": "TRIGGER",
"parentId": null,
"conditionParentId": null,
"schemaVersion": 3,
"type": "jira.manual.trigger.issue",
"value": {
"inputFromUsers": false,
"inputPrompts": [],
"groupIds": true,
"groups": [],
"issueFilter": null,
"jQLFilter": null
},
"children": [],
"conditions": [],
"connectionId": null
},
"components": [
{
"id": "562970759",
"component": "CONDITION",
"parentId": null,
"conditionParentId": null,
"schemaVersion": 1,
"type": "jira.comparator.condition",
"value": {
"first": "{{issue.customfield_10104}}",
"second": "",
"operator": "NOT_EQUALS"
},
"children": [],
"conditions": [],
"connectionId": null
},
{
"id": "562970761",
"component": "ACTION",
"parentId": null,
"conditionParentId": null,
"schemaVersion": 1,
"type": "codebarrel.action.log",
"value": "user is {{issue.fields.customfield_10104}}",
"children": [],
"conditions": [],
"connectionId": null
},
{
"id": "562970763",
"component": "CONDITION",
"parentId": null,
"conditionParentId": null,
"schemaVersion": 1,
"type": "jira.comparator.condition",
"value": {
"first": "{{issue.fields.customfield_10108}}",
"second": "",
"operator": "NOT_EQUALS"
},
"children": [],
"conditions": [],
"connectionId": null
},
{
"id": "562970765",
"component": "ACTION",
"parentId": null,
"conditionParentId": null,
"schemaVersion": 1,
"type": "codebarrel.action.log",
"value": "{{issue.fields.customfield_10108.value.replace(\" \", \"+\")}}",
"children": [],
"conditions": [],
"connectionId": null
},
{
"id": "562970767",
"component": "BRANCH",
"parentId": null,
"conditionParentId": null,
"schemaVersion": 1,
"type": "jira.smart.values.branch",
"value": {
"id": "_customsmartvalue_id_1722437278926",
"name": {
"type": "FREE",
"value": "name"
},
"type": "SMART",
"query": {
"type": "SMART",
"value": "{{issue.fields.customfield_10108.value.replace(\" \", \"+\")}}"
},
"lazy": false
},
"children": [
{
"id": "562970769",
"component": "ACTION",
"parentId": "562970767",
"conditionParentId": null,
"schemaVersion": 1,
"type": "codebarrel.action.log",
"value": "the taken value is {{name}}",
"children": [],
"conditions": [],
"connectionId": null
},
{
"id": "562970772",
"component": "ACTION",
"parentId": "562970767",
"conditionParentId": null,
"schemaVersion": 1,
"type": "jira.issue.outgoing.webhook",
"value": {
"url": "https://atl-test-rhameed2.atlassian.net/rest/api/3/group?groupname={{name}}",
"headers": [
{
"id": "_header_1722437089632",
"name": "",
"value": "",
"headerSecure": false
},
{
"id": "_header_1722437185678",
"name": "Authorization",
"value": "Basic cmhhbWVlZDJAYXRsYXNzaWFuLmNvbTpBVEFUVDN4RmZHRjBkaS1xejgzLTBHSmJBclFDdWJiQ0tHVDJXYUVXWE9XTEtveFhVR3A3WkV0a1lDeHlESm0xV1pINEdkVVhCaWxTOUhLT29heGp6LXdoMUQzRmFDdGxBdm1BMGkxcTA1dGtYdW1yVDZHOWRYSGs0YWJCaUJkNGIwbFJIOG1tTWF4NnpyM1l0QW5XUkRyd1FwckQ3WVZvcVdKSTFXZVAtTkx6NFdCSXpOTFc5aTA9NzI5QjJGMDU=",
"headerSecure": false
}
],
"sendIssue": false,
"contentType": "empty",
"customBody": "",
"method": "GET",
"responseEnabled": true,
"continueOnErrorEnabled": true
},
"children": [],
"conditions": [],
"connectionId": null
},
{
"id": "562970775",
"component": "ACTION",
"parentId": "562970767",
"conditionParentId": null,
"schemaVersion": 1,
"type": "jira.create.variable",
"value": {
"id": "_customsmartvalue_id_1723525036103",
"name": {
"type": "FREE",
"value": "groupidlist"
},
"type": "SMART",
"query": {
"type": "SMART",
"value": "{{webhookResponse.body.groupId}}"
},
"lazy": false
},
"children": [],
"conditions": [],
"connectionId": null
},
{
"id": "562970780",
"component": "ACTION",
"parentId": "562970767",
"conditionParentId": null,
"schemaVersion": 1,
"type": "codebarrel.action.log",
"value": "id are: {{webhookResponse.body.groupId}}",
"children": [],
"conditions": [],
"connectionId": null
},
{
"id": "562970785",
"component": "ACTION",
"parentId": "562970767",
"conditionParentId": null,
"schemaVersion": 1,
"type": "codebarrel.action.log",
"value": "group ID's are: {{groupidlist}}",
"children": [],
"conditions": [],
"connectionId": null
},
{
"id": "562970792",
"component": "ACTION",
"parentId": "562970767",
"conditionParentId": null,
"schemaVersion": 1,
"type": "codebarrel.action.log",
"value": "JSON: {{issue.customfield_10104.asJsonObjectArray(\"accountId\")}}",
"children": [],
"conditions": [],
"connectionId": null
},
{
"id": "562970795",
"component": "ACTION",
"parentId": "562970767",
"conditionParentId": null,
"schemaVersion": 1,
"type": "jira.create.variable",
"value": {
"id": "_customsmartvalue_id_1723531586144",
"name": {
"type": "FREE",
"value": "accid"
},
"type": "SMART",
"query": {
"type": "SMART",
"value": "{{issue.customfield_10104.asJsonObjectArray(\"accountId\")}}"
},
"lazy": false
},
"children": [],
"conditions": [],
"connectionId": null
},
{
"id": "562970799",
"component": "ACTION",
"parentId": "562970767",
"conditionParentId": null,
"schemaVersion": 1,
"type": "codebarrel.action.log",
"value": "accid: {{accid.remove(\"[\").remove(\"]\").replace(\"},{\",\",\")}}",
"children": [],
"conditions": [],
"connectionId": null
},
{
"id": "562970801",
"component": "ACTION",
"parentId": "562970767",
"conditionParentId": null,
"schemaVersion": 1,
"type": "jira.issue.outgoing.webhook",
"value": {
"url": "https://automation.atlassian.com/pro/hooks/c15981023fbd6ef7fc3ad70f2eb1bf05e15092fb?issue={{triggerissue}}",
"headers": [
{
"id": "_header_1723533045692",
"name": "",
"value": "",
"headerSecure": false
}
],
"sendIssue": false,
"contentType": "custom",
"customBody": "{\n \"issue\": {\n \"key\": \"{{triggerissue}}\",\n \"user\" : {{accid}},\n \"group\" : \"{{groupidlist}}\"\n }\n}",
"method": "POST",
"responseEnabled": true,
"continueOnErrorEnabled": false
},
"children": [],
"conditions": [],
"connectionId": null
},
{
"id": "562970802",
"component": "ACTION",
"parentId": "562970767",
"conditionParentId": null,
"schemaVersion": 1,
"type": "jira.issue.outgoing.webhook",
"value": {
"url": "https://webhook.site/85ea8944-4de2-4bf2-94de-5da1ee6959ad?issue={{triggerissue}}",
"headers": [
{
"id": "_header_1723533045692",
"name": "",
"value": "",
"headerSecure": false
}
],
"sendIssue": false,
"contentType": "custom",
"customBody": "{\n \"issue\": {\n \"key\": \"{{triggerissue}}\",\n \"user\" : \"{{accid}}\",\n \"group\" : \"{{groupidlist}}\"\n }\n}",
"method": "POST",
"responseEnabled": true,
"continueOnErrorEnabled": false
},
"children": [],
"conditions": [],
"connectionId": null
}
],
"conditions": [],
"connectionId": null
},
{
"id": "562970803",
"component": "ACTION",
"parentId": null,
"conditionParentId": null,
"schemaVersion": 1,
"type": "codebarrel.action.log",
"value": "{{groupidlist}}",
"children": [],
"conditions": [],
"connectionId": null
}
],
"canOtherRuleTrigger": false,
"notifyOnError": "FIRSTERROR",
"projects": [],
"labels": [],
"tags": [
{
"id": 83590806,
"ruleIdUuid": null,
"tagType": "IS_RULE_UPDATED",
"tagValue": "true"
}
],
"ruleScope": {
"resources": [
"ari:cloud:jira:be8a4606-6804-4215-b486-6b0057e1fa6f:project/10001"
]
},
"ruleHome": {
"ruleLifecycleHome": {
"locationARI": "ari:cloud:jira:be8a4606-6804-4215-b486-6b0057e1fa6f:project/10001"
},
"ruleBillingHome": {
"locationARI": "ari:cloud:jira-servicedesk::site/be8a4606-6804-4215-b486-6b0057e1fa6f"
}
},
"writeAccessType": "UNRESTRICTED",
"collaborators": [],
"billingType": "NORMAL",
"idUuid": "0191472a-f488-7876-8a9a-78ce5e1dd9a2"
}
]
}
This automation rule is intended to add multiple users to specific groups in Jira using webhook integrations. Here's an overview of how the rule works:
1. Trigger: The rule is triggered manually by an issue action in Jira (manual trigger on an issue). This allows users to initiate the rule when needed.
2. Conditions:
* The first condition checks if a custom field (customfield_10104) in the issue is not empty. Here customfield_10104 represents the field where the user details are added in jira issue.
* The second condition checks if another custom field (customfield_10108) is not empty. Here customfield_10108 represents the field where the user details are added in jira issue.
3. Actions:
* Log actions are used throughout the rule to provide debug information, logging various values like the user or group.
* The main action involves branching based on the value of customfield_10108. This value is transformed (replacing spaces with +), and a branch is created to process the group name stored in the field.
4. Webhooks:
* A webhook is called to retrieve the group ID from Jira's REST API based on the group name.
* Another webhook is used to pass user information (from customfield_10104) and the group ID obtained from the earlier webhook to a different service. This service likely handles adding users to the appropriate groups.
5. Custom Variables:
* The rule creates custom smart variables (groupidlist and accid) to store the group IDs and account IDs of the users. These are later used in the webhook payloads.
6. Final Webhooks:
* The rule sends POST requests to external endpoints https://automation.atlassian.com with the issue key, user account IDs, and group IDs in a custom JSON format. These endpoints likely process the addition of users to the groups.
NOTE: Make sure to replace customfield_10104 and customfield_10108 once the rule is imported to your instance.
This rule is also designed with logging at several stages to help troubleshoot or track its execution flow. The rule interacts with Jira's APIs and external systems through webhooks, making it capable of automating user management tasks based on custom issue data.
Rule 2: Add users to group
1. Trigger, here we use an Incoming webhook trigger, this incoming webhook doesn’t need authentication headers

2. Branch (jira.smart.values.branch):
* Type: SMART value-based branch.
* It uses the value {{webhookData.issue.user.accountid}} to perform actions for each user account ID involved.

* Inside the Branch:
* Action 1 (codebarrel.action.log): Logs the accountid for tracking.
* Action 2 (jira.issue.outgoing.webhook): Sends a POST request to an external service:
* URL: Sends a request to https://atl-test-rhameed2.atlassian.net/rest/api/3/group/user?groupId={{webhookData.issue.group}} to potentially add the user to a group.

* Headers: Includes an Authorization header with an encoded string (likely a basic authentication token).
* Body: The request sends a JSON payload with the user’s account ID: { "accountId": "{{accountid}}" }.
* Error Handling: The rule is configured to continue execution even if there is an error (continueOnErrorEnabled: true).
By combining these two rules, you can successfully add multiple users to multiple groups in a Jira issue.
Was this helpful?