I am trying to setup a build that needs a server to be started first. (It is an Android emulator.)
The emulator is started by a small script, which contains 2 lines:
export PATH=${PATH}:${ANDROID_HOME}/platform-tools:${ANDROID_HOME}/tools
emulator -avd 14 -no-window -noaudio &
When running the script manually, the emulator is started, and returns immediately, thanks to the & at the end of the line.
When I try running this in a Bamboo script task, the emulator starts properly, but the build is stuck there and never reaches the next task.
It does continue as soon as I stop the emulator on the machine.
For some reason, Bamboo is waiting for that process to end.
How could I avoid that?
I tried running the emulator as an inline script as well, but had the same behaviour.
I also tried running it in a bash subprocess, to detach it from the bamboo agent process, but it didn't work either:
bash -c emulator -avd 14 -no-window -noaudio &
It executes on a remote build agent running Linux.
Can you help me?
Thanks!
Here is something that worked for me:
nohup ./startup-server </dev/null>/dev/null 2>&1 &
Yeah, definitely... From my tests, the _nohup_ is actually not necessary, but the rest is. Thanks for the hint.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I too needed to start an Android emulator for running tests during my Android build. This is how I worked around the inability to start the emulator in the background.
My plan has one stage with two jobs. One job starts the emulator using the Android SDK emulator command. The other job waits for the emulator to start, builds the mobile app, runs the tests and then stops the running emulator using a final task that is always executed even if a previous task fails.
The emulator job does get "stuck" after starting the emulator. However, when the build job runs, the final task in the build job stops the emulator which causes the emulator job to finish because the emulator process is no longer running.
Here are the task details for build job:
Script task that does the following:
echo "Waiting 60 seconds for the Android emulator to start" sleep 60 echo "See if Emulator is up and running" ${bamboo.ANDROID_HOME}/platform-tools/adb devices ${bamboo.ANDROID_HOME}/platform-tools/adb -s emulator-5554 shell getprop dev.bootcomplete
Tasks to checkout the code from the repo and run the Gradle wrapper script to build the mobile app
Script task configured as a final task that does the following. This task causes the emulator job to finish.
echo "Stopping the Android emulator" ${bamboo.ANDROID_HOME}/platform-tools/adb -s emulator-5554 emu kill ${bamboo.ANDROID_HOME}/platform-tools/adb devices
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
What if you run your script with no input stream?
bash -c emulator -avd 14 -no-window -noaudio </dev/null &
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
We have created this as a bug that can be tracked at https://jira.atlassian.com/browse/BAM-11887
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
have you tried returning out of your script with a successful exit code? That usually halts the script.
For bamboo.. successful exit == 0
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.