Use EC2 ephemeral storage as build directory even with an EBS volume attached
Platform Notice: Data Center Only - This article only applies to Atlassian products on the Data Center platform.
Note that this KB was created for the Data Center version of the product. Data Center KBs for non-Data-Center-specific features may also work for Server versions of the product, however they have not been tested. 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
Scenario
When using Elastic Bamboo, an instance with an EBS volume attached will use /mnt/bamboo-ebs/bamboo-agent/build-dir/
as the place where it checks out code (instead of /home/bamboo/bamboohome/xml-data/build-dir/
when not using EBS). This is usually useful because future Elastic instances will avoid the need to do full checkouts from scratch (speeding up build time).
One downside with this approach is that EBS volumes are usually much smaller than the ephemeral storage supplied with most types of EC2 instances. If you have many plans, the checked-out code for each of them (sitting in the build directory, even after the build completes) could use up all the available space, eventually preventing builds from running until the build directory is manually cleaned out.
Solutions
If it's important for you that the code checkouts occur on the EBS volume then you will need to simply use a larger EBS volume.
If you don't care about the ability to persist code checkouts between elastic instances (e.g. you only use the EBS volume to customise the EC2 instance), then you can change the location the code is checked-out to by editing /mnt/bamboo-ebs/bin/customise-extras.sh
and adding the following lines:
1
2
3
4
5
6
7
8
# Create an alternative build directory on EC2 ephemeral storage
NEW_BUILD_DIR=/media/ephemeral0/build-dir
echo "Creating ephemeral build-dir at: ${NEW_BUILD_DIR}"
mkdir -p "${NEW_BUILD_DIR}"
chown bamboo:ec2-user "${NEW_BUILD_DIR}"
# Change agent configuration to point to the alternative directory
sed -i /mnt/bamboo-ebs/bamboo-agent/bamboo-agent.cfg.xml -e "s#/mnt/bamboo-ebs/bamboo-agent/build-dir/#${NEW_BUILD_DIR}#"
You will then want to generate a new EBS snapshot and modify your image configuration to use this new snapshot (you can read details on how to do this at: Configuring elastic instances to use the EBS).
Source code checkouts will now go under /media/ephemeral0/build-dir/
instead of using up space on the EBS volume. Of course, the checkouts will be lost once the Elastic instance shuts down.
Alternative:
Manually modify /mnt/bamboo-ebs/bamboo-agent/bamboo-agent.cfg.xml to point to /home/bamboo/bamboohome/xml-data/build-dir/
Was this helpful?