Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Unable to delete project using JIRA REST

Peter Tipping December 7, 2014

I am trying to split a project from an existing JIRA instance.  I have been provided with a XML backup, which I have restored.  New clone is running JIRA 6.2.2.

There are 117 Projects in the clone, and I only want to keep 1.  I started deleting them manually, and that works, but is tedious, and since I'll be doing this again later, once I have worked out the steps involved, it is going to be easier to automate this.

The JIRA REST API seems to be the answer to all of my problems.  I decided to use it via python, so installed jira-python via pip.

I can list out all of the projects.  I can identify the one I want to keep, and when I try to delete those I don't wish to keep, it doesn't fail, but, neither does it delete the projects?

I have tried reindexing after deleting the Projects, but that made no change.

from jira.client import JIRA

jira = JIRA(options = {'server': 'http://atsapaud02.toll.com.au:9090'}, basic_auth=('username', 'password'))

# Get all Projects
projects = jira.projects()
# delete those Projects that are NOT required
for project in projects:
    if project.key == 'TOL':
        print 'Leaving', project.key, '==>', project.name
    else:
        print 'Deleting', project.key, '==>', project.name,
        print jira.delete_project(project.key)

The JIRA REST documentation (https://docs.atlassian.com/jira/REST/6.2.2/) doesn't indicate that deleting a Project is available.  It appears the only parts of Projects that can be deleted programmatically is the avatar, properties and roles.

The JIRA Python documentation (http://jira-python.readthedocs.org/en/latest/) on the other hand, lists a delete_project method, which returns False if it fails.  In my case, it returns true, yet the Projects still exist.

3 answers

1 accepted

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

2 votes
Answer accepted
William Ing October 10, 2015

Peter, the delete_project() was implemented using normal HTTP calls inside the JIRA library. Mainly it works more like the browser. If I remember well removal of projects can take a lot of time and it does run in the background. So a False response could mean that deletion was not finished yet, or it failed for some reason.

0 votes
Charles Scott December 8, 2014

another failure by atlassian.  api is just a second class citizen.

0 votes
Nic Brough -Adaptavist-
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
December 8, 2014

REST does not currently support delete project, or in fact, most admin actions - https://docs.atlassian.com/jira/REST/6.2.2/ is the right place to look.

I'm not sure why the python docs don't tell you that to be honest.  They're either aspirational or they're using an additional addon that provides more REST functions

TAGS
AUG Leaders

Atlassian Community Events