Description
If you have large numbers of users that need to be added to groups, the CLI can be used to automate that procedure using the addUserToGroup action. In many cases, you might have definition of what users need to be added to what groups in a CSV file, the result of a SQL query, or just a plain text list in one form or the other. For example, this Confluence KB article describes a way of producing this type of information from a Confluence or Crowd directory.
The CLI has various built in actions for bulk operations like this that makes it easy to run a single action to import bulk data. Choice the method that works best for you based on the source of your data. See Reference for more details on the following actions:
- run
- runFromCsv
- runFromSql
AddUserToGroup
This base action is pretty simple: it requires a userId and group. There are some options to consider using as well:
- autoGroup - automatically creates a group if the group specified does not exist.
- preserveCase - by default and as a best practice, userIds (also referred to as usernames in Confluence) are lowercased. Use this option to preserve the cased if that is your standard.
- continue - use this option to ignore cases where the userId is already in the group. This normally should be use for bulk operations.
Example - RunFromCsv
We will use runFromCsv as an example, but similar techniques can be used for the other cases.
"userId", "group" admin, jira-administrators admin, jira-developers admin, jira-users
--action runFromCsv --file example.csv --continue --common "--action addUserToGroup --autoGroup --continue"