Email check when user creation - how to?

Rumceisz July 26, 2015

Hi Everyone,

we create users by a jelly script (soon by groovy) and in these cases we create bulk of them. It happens many times that we already have a user in our database and we create it once again. Is there a code snippet which checks whether an email address already registered in our DB and if yes, the user will not be created or JIRA warns us?

Thanks!

2 answers

0 votes
GabrielleJ
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
July 31, 2015

Really? JIRA allows you to re-use a username?

0 votes
Robert Dzido
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
July 26, 2015

In Groovy you can simply use getUserByEmail method.

import com.atlassian.crowd.embedded.api.User;
import com.atlassian.jira.user.UserUtils;

String emailAddress='my@address.com';
User user = UserUtils.getUserByEmail(emailAddress);
if (user==null){
  //create users here
}

Suggest an answer

Log in or Sign up to answer