I solved the issue in a very basic way. Each script below is executed as SSH to localhost as jobs in a Bamboo build plan that gets executed every night.
Prerequisites:
Generate an SSH key, added the private half to the build plan. The public half of the key was added to the bamboo user’s authorized keys file on each bamboo agent. This should never have to be done again.
Logic:
List out the build cache files and folders:
echo "Deleting the following build cache folders:"
find /home/bamboo/bamboo-agent-home/bin/ -name plan* -maxdepth 1}}
cd /home/bamboo/bamboo-agent-home/xml-data/
find build-dir/ -name C* -not -path "build-dir/repositoryData/*" -maxdepth 1
find build-dir/ -name T* -not -path "build-dir/repositoryData/*" -maxdepth 1
find build-dir/_git-repositories-cache -maxdepth 1
The above code lists out the folders that are deleted in the second half of the plan. I use -maxdepth 1 so only the target folders are listed, not the files and folders contained in them. This reduces the log file size and makes it easier to read. The last 4 lines are a bit interesting because we are only deleting folders that are not repositoryData which probably isn’t necessary, but the folder is relatively small, so I don’t see the need to delete it.
Delete the build cache files and folders:
echo "Deleting...."
rm -rf /home/bamboo/bamboo-agent-home/bin/plan*}}
rm -rf /home/bamboo/bamboo-agent-home/xml-data/build-dir/C*
rm -rf /home/bamboo/bamboo-agent-home/xml-data/build-dir/T*
rm -rf /home/bamboo/bamboo-agent-home/xml-data/build-dir/_git-repositories-cache
echo "Delete finished"
Making use of echo " " helps make the job logs easier to read because (by default) bamboo (or bash shell) doesn’t echo the commands as it runs them. There’s probably a bash function to do something like echo on but I don’t feel like messing with that today.
Screenshot: imgur /a/z1KTcfL
This has got to be THE WORST markdown editor I've ever used. Had to edit this at least 5 times because it kept adding random curly braces everywhere to my formatted text. {{ }}
I solved the issue in a very basic way. Each script below is executed as SSH to localhost as jobs in a Bamboo build plan that gets executed every night.
Prerequisites:
Generate an SSH key, added the private half to the build plan. The public half of the key was added to the bamboo user’s authorized keys file on each bamboo agent. This should never have to be done again.
Logic:
List out the build cache files and folders:
The above code lists out the folders that are deleted in the second half of the plan. I use -maxdepth 1 so only the target folders are listed, not the files and folders contained in them. This reduces the log file size and makes it easier to read. The last 4 lines are a bit interesting because we are only deleting folders that are not repositoryData which probably isn’t necessary, but the folder is relatively small, so I don’t see the need to delete it.
Delete the build cache files and folders:
Making use of echo " " helps make the job logs easier to read because (by default) bamboo (or bash shell) doesn’t echo the commands as it runs them. There’s probably a bash function to do something like echo on but I don’t feel like messing with that today.
Screenshot: imgur /a/z1KTcfL
This has got to be THE WORST markdown editor I've ever used. Had to edit this at least 5 times because it kept adding random curly braces everywhere to my formatted text. {{ }}