Created
May 2, 2021 05:49
-
-
Save vikrantyadav11/3d7d7da5efe970ce013179cb66c038ff to your computer and use it in GitHub Desktop.
New JIRA User in JIRA Default Directory
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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