Hi Team,
I have written groovy code like below but getting errors can anyone help me how to rectify this.
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
import com.atlassian.jira.ComponentAccessor
import com.onresolve.jira.groovy.user.FieldBehaviours
import com.onresolve.jira.groovy.user.FormField
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.Issue
import com.atlassian.jira.issue.IssueManager
import com.atlassian.jira.issue.CustomFieldManager
import com.atlassian.jira.issue.fields.CustomField
import com.atlassian.jira.issue.customfields.manager.OptionsManager
import com.atlassian.jira.issue.fields.config.FieldConfigImpl
import groovy.transform.BaseScript
File file = new File("C:/Users/edukondal.salwadi/Desktop/file.csv")
def csvMapList = []
file.eachLine { line ->
def columns = line.split(",")
def tmpMap = [:]
tmpMap.putAt("userName", columns[0])
tmpMap.putAt("userEmail", columns[1])
tmpMap.putAt("userFullName", columns[2])
csvMapList.add(tmpMap)
}
return csvMapList
Error:Getting below even though i have given correct path
java.io.FileNotFoundException: C:\Users\edukondal.salwadi\Desktop\file.csv (The system cannot find the path specified) at Script5775.run(Script5775.groovy:31)
Why not use Rest API to create the users?
You can use a csv with all information about users:
This makes it easier.
Regards
@Ismael Jimoh Did you mean to write a REST API Script that can check mapping from this CSV file and doing post method hitting our Instance directly? Sorry, I am not much into Code.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You do not need a special script as I mentioned build a collection (please look up building collection in postman).
You can pass environment information like url, username, password that you store in Postman.
Anyway read or watch a video that explains using collection in postman and how to manage environments.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
@Ismael Jimoh Yeah, I know how to use collections in postman. Of course, we have the script to add the user and check the user status against AD and then put the user in relevant group. But, I thought using the methods you shared above from Atlassian is only helping to add 1 user, not the bulk users right? Correct me if I wrong. I thought that we can post JSON in the REST API methods above for user by user only.
Thanks,
Srikanth Ganipisetty.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
@Srikanth Ganipisetty you mentioned you have the users in a csv file from my understanding.
The point of a collection is to run till it gets to the end of a file.
So if you upload your file with the list of users to be added to the collection, the collection keeps running creating your users you have listed in the file to the application.
This is no different that say you are creating users in the database, when you run the prepared queries, yes it will bulk create the entries, however inn reality, it is still running them line by line or user by user.
There is no way you can in one command create 2 users without parsing them iteratively.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi ,
You may be running into this issue - https://productsupport.adaptavist.com/browse/SRJIRA-2330?
Ensure that directory name has no spaces. You can copy and paste the exact path by doing a dir of that file in the command prompt. Seems like a permission issue to me. Try to use the path for which jira has all the permissions.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I have checked everything looks fine path and permissions.
Can you check any change required in code?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.