Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Build expiry can be managed using new support in BCLI. The new setExpiryOptions action  action is available with Version 9.3 or higher. The following assumes you have configured your Bamboo site or at least your build configuration to run the acli CLI script.

  1. Determine your expiry management criteria in terms of days for each type of data - artifacts, logs, and results (removing a build result also removes artifacts and logs).
  2. Create a build that runs on your own schedule and includes the follow script
Code Block
languagebash
themeMidnight
titleExample
#!/bin/bash -x

acli ${bamboo.localSite} -a run --continue \
  -i "-a setExpiryOptions --field artifacts --field expireAfter=2   --field buildsToKeep=5 --field maximumBuildsToKeep=5 --field deploymentsToKeep=5 --field labelsToKeep=keep " \
  -i "-a runBuildExpiry" \
  -i "-a setExpiryOptions --field logs      --field expireAfter=60  --field buildsToKeep=5 --field deploymentsToKeep=5   --field labelsToKeep=keep " \
  -i "-a runBuildExpiry" \
  -i "-a setExpiryOptions --field results   --field expireAfter=120 --field buildsToKeep=5 --field deploymentsToKeep=5   --field labelsToKeep=keep " \
  -i "-a runBuildExpiry"


Tip

Configure a global Bamboo variable to reference the local Bamboo instance site in your acli.properties configuration file that provides authentication. 


Tip

View your current global expiry settings to help you determine the last (results) setting. 

Explainer

This script sets Bamboo's global expiry with the custom field settings and then runs the expiry immediately. It repeats this for each of the data types.   

In the example above, we are very aggressive on removing artifacts unless the build has explicitly used the keep label. This is because we many testing builds and some have extensive Selenium screen captures that help with debugging build failures. Build failures should be investigated and debugged within a day or so, therefore we can remove early and save the space.

We keep the results much longer as they do not impact disk space much at all.

To understand the meaning of the field settings, go to the Bamboo global expiry screen or view the Atlassian documentation on this topic.