How to add user automatically to mentioned group in Jira

Pillai_ Aarthi
Contributor
January 5, 2023

Goal is to create a form in service desk and user will enter the jira group in which they want to be added, if the group exists then automatically add the user to that group

 

 

1 answer

1 accepted

2 votes
Answer accepted
Alex Koxaras _Relational_
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
January 5, 2023

Hi @Pillai_ Aarthi 

I don't think you can do that. That would be a possible security issue. Only org/site admins can add users to groups.

Pillai_ Aarthi
Contributor
January 5, 2023

I am an site admin, we are looking into automation to reduce our manual efforts 

Alex Koxaras _Relational_
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
January 5, 2023

In that case what I would try is to have a custom field on the form with all the groups and I would let the user choose the group.

And then with Jira automation I would send an http request to add this user to the selected group:

POST /rest/api/3/group/user

https://developer.atlassian.com/cloud/jira/platform/rest/v3/api-group-groups/#api-rest-api-3-group-user-post

Trial and error of the above is mandatory :)

Like # people like this
Pillai_ Aarthi
Contributor
January 17, 2023

Thank you @Alex Koxaras _Relational_ I was able to add users using this approach

But, I am able to add user to only 1 group, the automation fails if user has selected more than 1 group name.

Chandra babu
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
July 27, 2023

Hi Aarthi,

Hope you're doing well!  

Can please post all the steps with an example on how you have achieved it. 

Like Pillai_ Aarthi likes this
Pillai_ Aarthi
Contributor
July 27, 2023

@Chandra babu 

The goal is to automatically add the reporter (the person who raised the issue) to the groups specified in the "Group Addition" field whenever the value of that field is updated.

Here is an example of how you can achieve this using the Automation for Jira app and the Jira REST API:

1. First, you will need to set up a rule to trigger on the "Group Addition" field being updated.

2. First, you will need to add a "Send web request" action to the rule. This action will use the Jira REST API to update the reporter's groups.

3. In the "Send web request" action, you will need to specify the following details:

URL: This should be the URL of your Jira instance, followed by "/rest/api/3/group/user".

e.g HTTP method: POST

Headers:

You will need to include the "Content-Type" header with a value of "application/json" Authentication:

You will need to specify the authentication method that you are using to access the Jira REST API.

This could be basic authentication or OAuth, depending on your setup.

Body: You will need to include a JSON payload in the request body that specifies the groups to which you want to add the reporter.

The payload should look something like this:

{ "accountId": "{{issue.reporter.accountId}}", //reporter's accountId}

Like Chandra babu likes this
Harsh
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
December 19, 2023

Hi @Pillai_ Aarthi 

Any updates to this ? i cant add the reporter to the group. I am using Jira Data Center/Server. Can you please help me with the parsing,, where should I specify the group name. I tried with the webhook URL but no luck 

Thank you

Noah Dinlemez August 5, 2024

I'm actually in the proces of doing this with the same principle with API's, however one step more difficult: not everyone is allowed to join all the groups.

Therefore I've also set up Assets per group and added who the owners of the group are, so that only they can add/remove people from the group via a validation process.

It's quite an intensive use case, but will save me much time as admin as it will allow the, for example, product owners to let people join their team. 


To be able to add different groups, you will have to find a way to substitute te group id in the url to a smart value. However this is difficult, I managed to get it done by using assets and their attributes; to change the groupid to a plain text that is the same as the group id.

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
PREMIUM
PERMISSIONS LEVEL
Product Admin
TAGS
AUG Leaders

Atlassian Community Events