Android CI with satin bamboo

Does anyone have any good resources for setting up Bamboo to run CI with Android projects? I have my setup to pull the source and compile it with ant. But I would like to know how to configure JUnit tests where the tests are in a separate project.

thanks

+5
source share
2 answers

I figured out how to do this using Bamboo CI and new Android Studio projects with gradle. Bamboo doesn't have any good tasks yet, but you can use a script runner to do this. We set up our main build tasks as follows:

Checking the source code. Script task:

  • Script Location: Inline
  • Script Body: gradlew.bat assembleDebug test (our Bamboo server is Windows, so we use the bat file, linux uses the command. / Gradlew assembleDebug).

Then we add the final JUnit parser task, and we use the result directory line: ** / test-results / debug / *. xml

As for testing, we use Robolectric Gradle tests, which generate JUnit test results.

I hope this helps someone else who is setting up Bamboo with Android, hope that they will one day add support, as they do for .NET, where there is only one task that builds and tests. The script command seems to be hacked.

If someone is looking for Ant-style tests, I can share this too, but hopefully by this point everyone has switched to Android Studio from eclipse. I will say that the steps required for Ant and Instrumentation require much more time to configure, and I had to use an emulator running on the server to conduct the tests.

+2
source

In addition to using Bamboo to create an APK for my Android project, I also wanted to use Bamboo to run JUnit based tests against the Android emulator. After quite a few β€œtrial and error”, first of all, in finding a reliable way to start and stop the Android emulator, this is what I came up with for my Bamboo build plan. See Bamboo is waiting for a script job to complete, although it is running in the background for more reference on why I am using the approach described below.

My Bamboo plan has one step with two tasks. Tasks are performed using two agents that run on the same system. Both jobs start and run in parallel. One job launches the Android emulator using the Android SDK emulator command. Another task waits for the emulator to start, the mobile application to build, runs the tests with the emulator, and then stops the emulator running, using the final task, which is always performed even if the previous task in the build task fails.

The emulator task gets stuck after starting the emulator because it is waiting for the emulation process to complete. When the build job is running, the final task in the build job stops the emulator, which causes the emulator job to end because the emulation process no longer works.

Here is the basic information about the build task:

The first task is a script task that is waiting for the emulator to start. The following is the adb -s command, in which this task will not work if the emulator does not start.

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 -s emulator-5554 shell getprop dev.bootcomplete 

The second and third tasks check the source and create the application using Gradle. The assembly runs JUnit tests against a working emulator.

The fourth task, which is configured as the final task, is a script task that stops the emulator.

 echo "Stopping the Android emulator" ${bamboo.ANDROID_HOME}/platform-tools/adb -s emulator-5554 emu kill 
0
source

Source: https://habr.com/ru/post/1202396/


All Articles