Hey guys,
hope you can help me with this issue. We are using Jira 8.8.1 and I want to know if there is a way to bulk edit the user properties? I've got a lot of users and don't want to edit the properties manually for each of them.
I need something which checks for the name in a excel file and if the name fits it should add the Key="Example" Value="Value" which is also stored in the excel table.
Is this in any way possible to manage with a script or something else?
import com.opencsv.CSVReader
import com.atlassian.jira.component.ComponentAccessor
def userPropertyManager = ComponentAccessor.getUserPropertyManager()
def userManager = ComponentAccessor.getUserManager()
def groupManager = ComponentAccessor.getGroupManager()
@GRAPES(
@grab(group='com.opencsv', module='opencsv', version='4.2')
)
def filePath = '/home/jira/YourFileName.csv'
def reader = new CSVReader(new FileReader(new File(filePath)))
def data= reader.collect { it }.with { rows ->
def header = rows.head()
def dataRows = rows.tail()
dataRows.collect { row ->
[header, row].transpose().collectEntries()
}
}
data.each{row->
def userObject = ComponentAccessor.userManager.getUserByName(row['user_login'].toString())
userPropertyManager.getPropertySet(userObject)?.setString("jira.meta.Position",row['position'].toString())
}
This is best script for run from script runner console.
You but rows to your exel table and add data to rows? then you save as .csv this file and put it to your server.
Hi @Alibek Malikov
Thanks for the solution
I used your script
Is it possible for it to ignore non-existent users in Jira?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I do not have the example but I am sure that it is possible. You have to write it by yourself.
And you can use either JIRA API for example here:https://docs.atlassian.com/software/jira/docs/api/7.0.6/com/atlassian/jira/user/preferences/UserPreferencesManager.html
or JIRA REST API, for example here:
Lastly if you have script runner you can write the groovy script.
It does not mean that you need excel. Excel is just one of the possibility how to write that script. You can use groovy, java, java script, php or a lot of others.
But sorry I do not have a time to write it. Maybe somebody else will have some examples.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hey Vladimir,
thank you for the information. I will take a look into it!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
@Ye Fung Tchenhave you found a solution? If you have found a solution to the problem, can you tell me?
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.