Skip to content

Instantly share code, notes, and snippets.

@vikrantyadav11
Created May 2, 2021 05:49
Show Gist options
  • Select an option

  • Save vikrantyadav11/3d7d7da5efe970ce013179cb66c038ff to your computer and use it in GitHub Desktop.

Select an option

Save vikrantyadav11/3d7d7da5efe970ce013179cb66c038ff to your computer and use it in GitHub Desktop.
New JIRA User in JIRA Default Directory
import com.atlassian.jira.bc.user.UserService
import com.atlassian.jira.component.ComponentAccessor
def user = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser()
def userService = ComponentAccessor.getComponent(UserService)
UserService.CreateUserRequest createUserRequest = UserService.CreateUserRequest.
withUserDetails(user, "username", "password", "[email protected]", "Test User: user")
UserService.CreateUserValidationResult result = userService.validateCreateUser(createUserRequest)
if(result.isValid())
userService.createUser(result)
else
result.getErrorCollection()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment