Delete projects automatically in JIRA

G Krithica July 31, 2019

Hi ,

How to delete projects in jira automatically based on conditions like projects belonging to category A or project created before 2 years. The script or trigger should automatically check for condition and delete the projects without any manual intervention.

How to achieve this?

Thanks,

Krithica

2 answers

1 vote
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.
July 31, 2019

Technically, you can't do this.  Jira does not record when a project is created, so you have no date to work with.

That just means you need a different rule.  I'd base a rule on looking for the earliest created issue (which is an approximation for "project created") and maybe also check "last updated" or "last created" issue for a sanity check on if the project is still actively used.

Then, yes, use one of the automation apps to code a script to do this.  You'll need Scriptrunner or Powerscripts (I'm not sure this can do it, but I don't want to look like I'm selling SR as the only option)

Be warned though, you must think about backups before trying anything like this.  Deleted projects are gone, completely, and there's no way to get them back other than from a backup, so one error, and you could destroy something you need.

I'd also look at housekeeping - deleting a project destroys the header and all the issues in it, but leaves all the config behind.  You might want to look at something that kills off unused schemes (and fields) after a project deletion as well.

G Krithica July 31, 2019

I want to delete the projects that are archived  before 2 yrs. The script/listerener should delete those projects ? is this possible?

Thanks,

Krithica

0 votes
DPKJ
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
July 31, 2019

You can do that using CRON jobs and Jira's rest API.

  1. Just make a curl request to fetch all projects
  2. Find those that match your criteria
  3. Make a curl request to delete them one by one.

This fetch all project in JSON format

curl --request GET \
  --url '/rest/api/3/project' \
  --header 'Authorization: Bearer ' \
  --header 'Accept: application/json'

 

This deletes project,

curl --request DELETE \
  --url '/rest/api/3/project/{projectIdOrKey}' \
  --header 'Authorization: Bearer ' 
Suresh Venkat December 23, 2021

Does this REST API call delete project and its configurations (workflows, if not shared), screen(if no shared) etc. or it is just a doing what we do in the front-end - Deleting project's data and Nothing else.

Suggest an answer

Log in or Sign up to answer