We have a process in which service desk agents invite new users into their respective portals.
Now we also have (legacy) process in place by which certain customers gain access to confluence by manual assignment to a specific group.
Currently, this process requires the sd agent to create a jira issue to request adding the user to the group and then an admin adds the user to the group manually.
We want to automate this. We have the scriptrunner Addon but as far as we know there is know way to maintain group membership via Scriptrunner.
What other ways do we have to automate this process?
The last resort would be to build a python app that checks for such tasks in intervals and assigns the respective user and closes the ticket but this feels "hacky".
Hello!
To automate this process, you need to use an API token with admin permissions, as ScriptRunner cannot manage group membership directly without appropriate permissions. Below is an example script you can use
import org.slf4j.LoggerFactory
def logger = LoggerFactory.getLogger(this.class)
// Define the group name and the user
def groupName = "Test%20Correo%20Script" // Spaces encoded as %20
def userAccountId = "634xxxxxxxxxxxxxx"
// API Token
def apiToken = "YOUR_API_TOKEN"
def email = "example@example.com"
// Send the request to add the user to the group
def response = post("/rest/api/3/group/user?groupname=${groupName}")
.header("Authorization", "Basic ${"${email}:${apiToken}".bytes.encodeBase64().toString()}")
.header("Content-Type", "application/json")
.body([
accountId: userAccountId
])
.asString()
if (response.status == 201) {
logger.info("User successfully added to the group ${groupName}.")
} else {
logger.error("Error adding user to the group. Status: ${response.status}, Message: ${response.body}")
}

You will only have to add the conditions you want, but with this you already have the basis to be able to add users to groups.
To give you an idea, you can place a field in the ticket that specifies the group, and in the script you map the option with the group and the conditions that you can add additionally.
You can certainly write a script to use the Organization APIs to add users to groups, or the older Jira APIs.
Atlassian don't offer anything other than the APIs to make this easier or automated for you unfortunately.
This is specifically why we built the Admin Automations app, to allow users to be automatically put into groups based on other group membership and other attributes.
Today, it allows you to automate group memberships based on other groups. But soon we'll be releasing automations based on user attributes and a range of other features (more details on our website and roadmap).
I hope that was helpful, hit me up on email via our website if you want to chat more.
-Kieren
Co-Founder @ Admin Automation | Ex-Atlassian
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi, thanks for the quick answer. Sadly, this doesn't look as if it could help our use case. I'm not really sure but from the looks of it the current state for automated processes revolves around SCIM synced groups which is not the case for our use case.
Will keep an eye on the plugin though!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
SCIM sync is certainly one of our main use cases, but it’s not the only one.
I’m interested in knowing more about your use case, how would you want to automate the users being added to groups? Is there an attribute on the user or the jira ticket (like a group picker) that determines which group to add the user to?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.