@com.adaptavist.hapi.platform.analytics.Tracked class Users extends java.lang.Object
Type | Name and description |
---|---|
com.atlassian.jira.user.ApplicationUser |
loggedInUser |
com.atlassian.jira.user.ApplicationUser |
loggedInUser |
Constructor and description |
---|
Users() |
Type Params | Return Type | Name and description |
---|---|---|
|
static com.atlassian.jira.user.ApplicationUser |
create(java.lang.String username, java.lang.String emailAddress, java.lang.String displayName, groovy.lang.Closure<?> specification) Creates a new user. |
|
static com.atlassian.jira.user.ApplicationUser |
getByKey(java.lang.String userKey) Retrieves an ApplicationUser by key |
|
static com.atlassian.jira.user.ApplicationUser |
getByName(java.lang.String username) Retrieves an ApplicationUser by name |
|
static com.atlassian.jira.user.ApplicationUser |
getLoggedInUser() Get the current logged in user, may be null |
<T> |
static T |
runAnonymously(java.util.concurrent.Callable<T> callable) Run an action with no logged in user, returning the result, example usage: def issue = Users.callAs(Users.getByName('username')) { Issues.create('SR', 'Task') { summary = 'Help' } } |
<T> |
static T |
runAs(java.lang.String username, java.util.concurrent.Callable<T> callable) Run an action as a different user, returning the result, example usage: def issue = Users.callAs('username') { Issues.create('SR', 'Task') { summary = 'Help' } } |
<T> |
static T |
runAs(com.atlassian.jira.user.ApplicationUser applicationUser, java.util.concurrent.Callable<T> callable) Run an action as a different user, returning the result, example usage: def issue = Users.callAs(Users.getByName('username')) { Issues.create('SR', 'Task') { summary = 'Help' } } |
|
static void |
setLoggedInUser(java.lang.String username) Set the current logged in user by name |
|
static void |
setLoggedInUser(com.atlassian.jira.user.ApplicationUser applicationUser) Set the current logged in user |
Methods inherited from class | Name |
---|---|
class java.lang.Object |
java.lang.Object#wait(long, int), java.lang.Object#wait(long), java.lang.Object#wait(), 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() |
Creates a new user.
Users.create('jbloggs', 'joe@example.com', 'Joe Bloggs')You can further customise the creation process:
import com.atlassian.jira.application.ApplicationKeys Users.create('jbloggs', 'joe@example.com', 'Joe Bloggs') { password = 'supersecretpassword' directoryId = 10001 withApplicationAccess(ApplicationKeys.SERVICE_DESK) // etc }To sign up a user without setting a password:
Users.create('jbloggs', 'joe@example.com', 'Joe Bloggs') { sendUserSignupEvent() }
Retrieves an ApplicationUser by key
userKey
- the key of the user to retrieveRetrieves an ApplicationUser by name
username
- the name of the user to retrieveGet the current logged in user, may be null
Run an action with no logged in user, returning the result, example usage:
def issue = Users.callAs(Users.getByName('username')) { Issues.create('SR', 'Task') { summary = 'Help' } }
callable
- the action to run, which returns a resultRun an action as a different user, returning the result, example usage:
def issue = Users.callAs('username') { Issues.create('SR', 'Task') { summary = 'Help' } }
username
- user to run the action ascallable
- the action to run, which returns a resultRun an action as a different user, returning the result, example usage:
def issue = Users.callAs(Users.getByName('username')) { Issues.create('SR', 'Task') { summary = 'Help' } }
applicationUser
- user to run the action ascallable
- the action to run, which returns a resultSet the current logged in user by name
username
- name of user to be set as the logged in userSet the current logged in user
applicationUser
- the user to be set as the logged in userGroovy Documentation