@com.adaptavist.hapi.cloud.analytics.CloudTracked @com.onresolve.scriptrunner.hapi.annotation.Implements(parentInterface: UsersApi) class Users extends java.lang.Object
Provides convenience methods for retrieving Jira user information.
These methods return User objects, allowing you to work with user details without having to navigate the underlying Jira REST API complexities. Use them to:
// Get the currently logged-in user
def currentUser = Users.getLoggedInUser()
println "Logged-in User Account ID: ${currentUser.accountId
"
// Retrieve a user by account ID
def someUser = Users.getByAccountId("5b10a2844c20165700ede21g")
println "User Display Name: ${someUser.displayName}"
}
Constructor and description |
---|
Users() |
Type Params | Return Type | Name and description |
---|---|---|
|
static User |
getByAccountId(java.lang.String accountId) Retrieves a user by their Atlassian account ID. |
|
static User |
getByKey(java.lang.String key) Retrieves a user by key, interpreted here as an account ID. |
|
static User |
getLoggedInUser() Retrieves the currently logged-in user's information. |
Methods inherited from class | Name |
---|---|
class java.lang.Object |
java.lang.Object#wait(long, int), java.lang.Object#wait(), java.lang.Object#wait(long), java.lang.Object#equals(java.lang.Object), java.lang.Object#toString(), java.lang.Object#hashCode(), java.lang.Object#getClass(), java.lang.Object#notify(), java.lang.Object#notifyAll() |
Retrieves a user by their Atlassian account ID.
Use this method when you know the account ID of the user you want to fetch.
Account IDs can be found programmatically via other endpoints or by browsing
the Jira Cloud people directory: https://<your-domain>.atlassian.net/people
.
def user = Users.getByAccountId("5b10a2844c20165700ede21g")
println "User Display Name: ${user.displayName
"
}
accountId
- the account ID of the user to retrieveRetrieves a user by key, interpreted here as an account ID.
This method is a shorthand for getByAccountId(String), treating the given key as an account ID. If you are unsure whether to use this or getByAccountId(String), default to getByAccountId(String) for clarity.
Example Usage in Groovy:def user = Users.getByKey("5b10a2844c20165700ede21g")
println "User Display Name: ${user.displayName
"
}
key
- treated as an account ID of the user to retrieveRetrieves the currently logged-in user's information.
This method is useful when you need details about the user running the script, such as their account ID or display name.
Example Usage in Groovy:def currentUser = Users.getLoggedInUser()
println "Current User: ${currentUser.displayName
"
}