Reputation: 93
Using the Jira CLI, is there a way to remove a user from all project roles as well as from any issue they are listed as a watcher as? Doing this manually for each project would be extremely time consuming and prone to error. From the CLI examples at https://bobswift.atlassian.net/wiki/display/JCLI/Examples it looks like the watcher can only be removed on an issue by issue basis (using the removeWatchers command) and the project role actors can only be removed on a per project and role for project basis (using the removeProjectRoleActors command).
I would prefer the solution to be a CLI command, but a Groovy Script could be acceptable as well. If at all possible, I would prefer to not manually remove this data from the database. Any help would be appreciated as I am not finding much in the way of accomplishing this via CLI.
Upvotes: 0
Views: 929
Reputation: 111
While there are no dedicated actions for what you're talking about, it's very popular to combine actions with runFrom[whatever] actions in order to perform them in bulk.
Cleaning up watches can be done in one line by using the runFromIssueList action. An example would be:
jira --action runFromIssueList --jql "watcher = username" --common "--action removeWatchers --issue @issue@ --userId username"
Role clean-up is more complicated, but probably still faster than doing it directly within the JIRA UI. There will be two JIRA CLI commands to run overall, but a bunch of stuff to do in between them:
jira --action getProjectRoleByUserList --userId username --file rolelist.csv
// that action can take a LONG time to finish - do something else for a while
// now edit the heck out of the CSV to prepare it for the next step
jira --action runFromCsv --file rolelist_edited.csv --common "--action removeProjectRoleActors --userId username"
The CSV you'll get from the first command will have one row per project and one column per project role. Values will be Yes/No based on the user's permissions. You'll have to massage the Yes values into a new two column table with [project] [role] headers, one row for every Yes in the original table.
If the user is in a lot of roles across a lot of projects and this feels overwhelming, do an internet search for "unpivot" and the name of your spreadsheet editor, and you might find some shortcuts.
Upvotes: 1
Reputation: 6881
I think you'd need to do this using a Script Runner groovy script. The remote APIs don't expose the necessary methods. Also, if this is for a user who is deactivated, you can leave them as watchers and in project roles for historical reference.
Upvotes: 0