Automated EBS snapshots in Bamboo onDemand

I use Bamboo onDemand, which uses Amazon EC2, to build my project. After building it, I would like to create a new snapshot of the EBS volume, so I can use it later in another Amazon EC2 instance and run the built project.

I voted for this proposal to be developed: Provide functionality for automated EBS snapshot updates

But I can't wait for it to be developed, so I followed these steps to do it manually:

This works ok, but I need that Bamboo does that for me, so I made this script:

echo 'Superuser...'
sudo su
echo 'Moving outside the EBS volume...'
cd /
echo 'Killing all java processes...'
killall java
echo 'Generating new snapshot...'

If I run this script connected to the instance by ssh, it works, but then I tried to use it from Bamboo, and it doesn't. I used the Command task, placing my script inside the job folder, so it could be visible. And I also used the Script task, pasting that code in the "script body" field, but both ways didn't work.

It is wierd because the log doesn't show the echo messages that I added to the script. Is this normal? Do you know how could I make this script work?

Thank you very much.

4 answers

0 votes

The problem is that 'sudo su' does not grant root rights to the current session, it opens a new one with root rights.

Assuming you have passwordless sudo set up, does changing the script to

sudo killall java



Hello, Przemek, thank you for your answer. I did what you suggested, so the modified script is:

echo 'Moving outside the EBS volume...'
cd /
echo 'Killing all java processes...'
sudo killall java
echo 'Generating new snapshot...'

But there must be some password, because I get this error:

sudo: no tty present and no askpass program specified

I also tried "sudo -S ...", but I get a similar error. Then, from the terminal, I added bamboo user to the sudoers file, so it doesn't require a password to run sudo. And now I get this error:

Killing all java processes...

sudo: : command not found

Any idea? I will keep on investigating to solve the problem.

When I run the script connected to the instance by ssh, I need to remove the "sudo su" line, and execute that command before executing the script. I tried to do the same in Bamboo using two Command tasks, the first one for "sudo su", and the other one for the script, but it failed in the sudo step.

0 votes

Try using /usr/bin/sudo instead of sudo

So did it work using /usr/bin/sudo or was this a dead end? Can you share what you ended up doing Carlos?

Suggest an answer

Log in or Sign up to answer
Community showcase
Posted Tuesday in Statuspage

Introducing Statuspage Getting Started guides! First up: What is Statuspage?

Over the next several weeks we'll be sharing some of our Getting Started guides here in the community. Throughout this series of posts, we'd love to hear from customers and non-customers ab...

185 views 4 1
Join discussion

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you