Add users to JIRA group

This is a tutorial which could happen if you have set up access control in JIRA. In this example, we will use the Reporter as the user that shall be added.

Assumption

There is a group called Warehouse, your group can be named anything else as long as you can follow along.

In my example Rick is in the group as members. Now we want the user mr.bot to be added when the issue is approved.

Steps

  1. Create a new Action by clicking CREATE button
  2. Enter a name: Add users to JIRA group and click CREATE
  3. Select Method: POST and URL: <your_base_url>/rest/api/2/group/user?groupname=Warehouse
    rom the Atlassian REST API we can read that to add a user to a group we need to call POST /rest/api/2/group/user
  4. Select Authentication method: Basic Auth, specify an admin user that can add users to groups in JIRA.
  5. Add request headers, key: Content-Type with value application/json
  6. On the Body section add the following

    {
    	"name":"{{issue.reporter.username}}"
    }

    Here we use the mustache syntax to grab the user name of the reporter.

  7. Click Triggers tab
  8. Select ISSUE RESOLVED event, in this example we will use the Issue Resolved event to indicate that the user shall be added. 
  9. On JQL Condition. When to execute the event(s) write Project = TESTB and to limit the trigger to the TESTB project
  10. Click SAVE
  11. (Optional) Click Test button (no issue key is needed) to and click Send, Then go 3 - View Execution Log.

Result will have a response like the one below:

{
"name": "Warehouse",
"self": "http://localhost/rest/api/2/group?groupname=Warehouse",
"users": {
"size": 2,
"items": [],
"max-results": 50,
"start-index": 0,
"end-index": 0
},
"expand": "users"
}

Optional steps to inform the reporter about being added is to create a chained action that comments the issue.