Just a heads up: On March 24, 2025, starting at 4:30pm CDT / 21:30 UTC, the site will be undergoing scheduled maintenance for a few hours. During this time, the site might be unavailable for a short while. Thanks for your patience.
×Bulk uploading users into Jira can be confusing. I found a few scripts and put them together into one script. This does require ScriptRunner and access to your server's folders.
I started out using the Script Editor for the code and then used Console to execute the script. The Editor allows me to save the file for later use.
The users were loaded into a CSV with User ID, Password, Email Address and Display Name. We use single sign on so the password value was empty.
I uploaded the file to our server so the script could access it.
Hope this helps someone in the future.
/*
CSV Format
user ID, Email, full name
CSV parsing code copied from: https://stackoverflow.com/questions/49675423/read-csv-file-and-put-result-in-a-map-using-groovy-without-using-any-external-l
*/
import com.atlassian.jira.bc.user.UserService
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.bc.user.UserService.CreateUserRequest
import com.atlassian.jira.bc.user.UserService
import com.atlassian.jira.component.ComponentAccessor
File file = new File("//homedev/isdev//Persons.csv")
def csvMapList = []
file.eachLine { line ->
def columns = line.split(",")
// the username of the new user - needs to be lowercase and unique - required
String userName = columns[0]
// The password for the new user - if empty a random password will be generated
String password = ""
// The email address for the new user - required
String emailAddress = columns[1]
// The display name for the new user - required
String displayName = columns[2]
// notifications are sent by default, set to false to not send a notification
boolean sendNotification = false
def loggedInUser = ComponentAccessor.jiraAuthenticationContext.loggedInUser
def userService = ComponentAccessor.getComponent(UserService)
// see if this user already has an account
def user = ComponentAccessor.userManager.getUserByName(userName)
// new user
if (user == null) {
log.warn("add user "+columns[0]+ " "+ columns[1]+ " "+ columns[2])
def newCreateRequest = UserService.CreateUserRequest.withUserDetails(loggedInUser, userName, password, emailAddress, displayName)
.sendNotification(sendNotification)
def createValidationResult = userService.validateCreateUser(newCreateRequest)
assert createValidationResult.valid : createValidationResult.errorCollection
userService.createUser(createValidationResult)
}
}
Will this work for Service Management users?
It should work for Service Management users since the underlying user context is probably the same.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.