简体   繁体   English

JIRA CLI从所有项目的所有角色中删除用户,并从所有问题的观察者中删除用户

[英]JIRA CLI remove user from all roles for all project and remove user from watcher for all issues

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? 使用Jira CLI,是否可以将用户从所有项目角色以及作为监视程序列出的任何问题中删除? 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). 从位于https://bobswift.atlassian.net/wiki/display/JCLI/Examples的CLI示例中,看来只能逐个问题地删除观察者(使用removeWatchers命令),而项目角色参与者只能将根据项目和角色(基于remove)被删除(使用removeProjectRoleActors命令)。

I would prefer the solution to be a CLI command, but a Groovy Script could be acceptable as well. 我希望解决方案是CLI命令,但是Groovy脚本也是可以接受的。 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. 任何帮助将不胜感激,因为我在通过CLI来完成此任务方面找不到太多的东西。

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. 尽管没有针对您所讨论内容的专用动作,但是将动作与runFrom [whatever]动作组合在一起以批量执行它们非常流行。

Cleaning up watches can be done in one line by using the runFromIssueList action. 可以使用runFromIssueList操作在一行中清理手表。 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. 角色清理更为复杂,但可能仍比直接在JIRA UI中完成清理更快。 There will be two JIRA CLI commands to run overall, but a bunch of stuff to do in between them: 整体上将有两个JIRA CLI命令运行,但是在它们之间有很多工作要做:

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. 从第一个命令获得的CSV将在每个项目中包含一行,而每个项目角色中包含一行。 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. 您必须将Yes值添加到带有[project] [role]标头的新的两列表中,原始表中的每个Yes一行。

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. 如果用户在许多项目中都担任过许多角色,并且感到不知所措,请在Internet上搜索“ unpivot”和电子表格编辑器的名称,然后可能会找到一些快捷方式。

I think you'd need to do this using a Script Runner groovy script. 我认为您需要使用Script Runner groovy脚本来执行此操作。 The remote APIs don't expose the necessary methods. 远程API没有公开必要的方法。 Also, if this is for a user who is deactivated, you can leave them as watchers and in project roles for historical reference. 此外,如果这是针对已停用的用户的,则可以将其保留为观察者,并保留其项目角色以供历史参考。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM