How to delete Bamboo projects and plans in bulk using REST API

Still need help?

The Atlassian Community is here for you.

Ask the community


Platform notice: Server and Data Center only. This article only applies to Atlassian products on the Server and Data Center platforms.

Support for Server* products ended on February 15th 2024. If you are running a Server product, you can visit the Atlassian Server end of support announcement to review your migration options.

*Except Fisheye and Crucible

 

The steps outlined on this article are provided AS-IS. This means we've had reports of them working for some customers — under certain circumstances — yet are not officially supported, nor can we guarantee they'll work for your specific scenario.

You may follow through and validate them on your own non-prod environments prior to production or fall back to supported alternatives if they don't work out.

We also invite you to reach out to our Community for matters that fall beyond Atlassian's scope of support!

Summary

This article outlines the process to delete Bamboo projects and plans in bulk using REST API.

Environment

This has been tested on Bamboo 8.0.9 but likely works with other versions as well.

Solution

To delete the Projects in bulk via REST API we need to execute the API call in a script. You can put the Project_Key is a file say PROJECT_KEY, then read the file line by line and call the API against each line:

Script to delete projects in bulk using RESTAPI
#!/bin/bash
input="/<PATH>/PROJECT_KEY.txt"
username="admin"
password="****"
######################################
# Script to remove projects(empty ones) in bulk # 
#####################################
while read -r line
do
  echo "$line"
  curl -k -u "$username:$password" -X DELETE --url https://<BAMBOO_URL>/bamboo/rest/api/latest/project/$line
done < "$input"



********************
Example contents of the file PROJECT_KEY.txt

cat PROJECT_KEY.txt
PROJ1
PROJ2
PROJ3
PROJ4


The below script is to remove plans in bulk via REST API. PLAN_KEY file should have the list of the planKeys, e.g PROJ-PLAN:

Script to delete plans in bulk
#!/bin/bash
input="/<PATH>/PROJ_KEY-PLAN_KEY.txt"
username="admin"
password="****"
######################################
# Script to remove plans in bulk # 
#####################################
while read -r line
do
  echo "$line" 

curl -u "$username:$password" -X DELETE --url 'http://<BAMBOO_URL>/rest/api/latest/plan/$line'

done < "$input"


********************
Example contents of the file PROJ_KEY-PLAN_KEY.txt

cat PROJ_KEY-PLAN_KEY.txt
PROJ1-PLAN1
PROJ2-PLAN2
PROJ3-PLAN3
PROJ4-PLAN4

  Please make sure you have a backup in place before you run the REST API to delete, this might be required in case of rollback.


Kindly make sure to test these REST APIs in a test environment before running them in production to eliminate any risk. 

Last modified on Feb 28, 2024

Was this helpful?

Yes
No
Provide feedback about this article
Powered by Confluence and Scroll Viewport.