What I want to accomplish: get a list of all the Jira instance active users and the projects and project roles they belong to by calling all the projects and then iterating through the project roles and getting all the actors.
I'm working with ~500 active users
I've only used ScriptRunner on DC and at a novice level or manipulating existing scripts and there's a lot missing in Cloud so I've been unsuccessful in converting a DC script to Cloud, so I started with an existing Cloud script and I'm stuck and could use some help.
I've anonymized the script I'm working with and pasted it below.
I can successfully get all the project information but unsuccessful in project roles and actors. AND if I try to return the results formatted, I only get the query parameters spit back out, nothing about the projects.
NOTE: I am OK if output is by project and I have to scrub the data and sort it to merge all the results for a user (example: user Jacob McCarthy is in project A as developer, user Jacob McCarthy is in project B as administrator, user Jacob McCarthy is in project F as collaborator)
What I errors I know exist (I don't know how to fix them) -
Iterating the role ID into the API call (id isn't a class -- is the error I get)
import groovy.json.JsonSlurper
// String buffer to hold results
def sb = []
// Get list of all the projects
def getProjects = get("https://your-domain.atlassian.net/rest/api/3/project/search")
.header('Content-Type', 'application/json')
.asJson()
// Get JSON body contents of the HTTP response
def content = getProjects.body
// Turn raw body into JSON
def json = new JsonSlurper().parseText(content.toString())
json.each { project ->
sb.add(project['key'])
// For each project, get the list of roles
def getRoles = get("https://your-domain.atlassian.net/rest/api/3/project/${project.key}/role")
.header('Content-Type', 'application/json')
.asJson()
getRoles.body.each { role ->
def roleId = id
def getRoleMembers = get("https://your-domain.atlassian.net/rest/api/3/role/${roleId}/actors")
.header('Content-Type', 'application/json')
.asJson()
getRoleMembers.body.actors.each { roleMember ->
sb.add("${role.actor}: ${roleMember.displayName}")
}
}
}
return sb
I have also