Bulk delete JIRA projects, groups, users

George Bica November 28, 2016

I am creating this questions in response to Atlassian's lack of bulk tools to process JIRA content. I will supply the solution so other people can learn from my experience.

2 answers

1 accepted

0 votes
Answer accepted
George Bica November 28, 2016

Install the following from marketplace:

Download the latest CLI client from https://bobswift.atlassian.net/wiki/display/ACLI/CLI+Client+Installation+and+Use

Extract the contents inside the server in a folder.

Modify the file jira.bat so the --server, --user and --password fields are populated

java -jar "%dirPath%"/lib/jira-cli-6.0.0.jar --server http://server.dev.domain.com:80 --user sysadmin --password sysadmin %*

verify java.exe is in the Windows path (C:\Program Files\Atlassian\JIRA\jre\bin)

Notes:

  • Users that have contributed to the project will not be deleted from the script even if they are mentioned.
  • Do not delete users needed to login, such as sysadmin or IDs related to plugins.
  • Use the examples page to perform cleanup of projects, users and groups: https://bobswift.atlassian.net/wiki/display/JCLI/Examples
  • data from the export scripts will need to be cleaned up manually, only group name, userid or project key is needed
  • attachments are not deleted when a project is deleted via CLI at C:\Program Files\Atlassian\Application Data\JIRA\data\attachments.

Example CMD files

get all listed projects to CSV file

@echo off

rem remember the directory path to this bat file

set dirPath=%~dp0

call jira.bat --action getProjectList --outputFormat 2 --file groups-export.csv

pause

delete a list of projects from CSV file

@echo off

rem remember the directory path to this bat file

set dirPath=%~dp0

For /F "usebackq tokens=1  delims=," %%a in (projects-delete.csv) Do (

call jira.bat --action deleteProject --project "%%a" --continue

)

pause

Get list of groups to CSV file

@echo off

rem remember the directory path to this bat file

set dirPath=%~dp0

call jira.bat --action getGroupList --file groups_export.csv

pause

delete all listed groups from CSV file

@echo off

rem remember the directory path to this bat file

set dirPath=%~dp0

For /F "usebackq tokens=1  delims=," %%a in (groups_delete.csv) Do (

call jira.bat --action removeGroup --group "%%a" --continue

)

pause

get list of users to CSV file

@echo off

rem remember the directory path to this bat file

set dirPath=%~dp0

call jira.bat --action getUserList --name "@all" --outputFormat 2 --file users-export.csv --includeInactive

pause

delete users from a CSV file

@echo off

rem remember the directory path to this bat file

set dirPath=%~dp0

For /F "usebackq tokens=1  delims=," %%a in (users-delete.csv) Do (

call jira.bat --action removeuser  --userId "%%a" --continue

)

pause

Cameron August 14, 2017
  • Hi george,

I can't quite get the 'delete users from a CSV file' to function, are you able to provide further info of what should be directly entered into the CLI? (java.exe in in correct path, jira.bat file updated with necessary details)

George Bica August 15, 2017

Hello Cameron,

"delete users from a CSV file" is an example batch script file (.BAT or .CMD extension) that takes user names to delete from a CSV file called "users-delete.csv"

This CSV file is actually generated from the "get list of users to CSV file" script. You will need to masage the CSV file to remove any users you want to keep before moving to the delete phase, as well as remove any redundant data from it so the delete script can take only usersnames as input.

Edit1:

The script that exports users to CSV has many columns

User,Key,Name,Email,Time Zone,Avatar URL,Active,Groups

You need to remove every column exctept "User".

Edit2:

"get list of users to CSV file" scrip creates users-export.csv

This file has many columns.

User,Key,Name,Email,Time Zone,Avatar URL,Active,Groups

You need to remove every column except "User" then save the file as users-delete.csv

This new file can be used as input for "delete users from a CSV file" script.

0 votes
david
Solutions Partner
Solution Partners provide consulting, sales, and technical services on Atlassian products.
August 31, 2018

Hi @George Bica, Profields in its recent release allows performing bulk delete projects including their "orphan" schemes. Also allows to bulk change roles, components, project lead, and category.

Cheers,

David

bulkops.jpeg

Suggest an answer

Log in or Sign up to answer