 <p>You need to check the exit code of every adb statement you are running before moving onto the next</p> <p>This post here details checking exit codes with bash <a href="http://stackoverflow.com/questions/5195607/bash-beginner-check-exit-status">Bash Beginner Check Exit Status</a></p> <p>which includes this (changed for your example)</p> <pre><code>function test { "$@" status=$? if [ $status -ne 0 ]; then echo "error with $1" exit "$status" fi return $status } test adb shell uiautomator runtest myTest.jar -c com.myTest.TestClass1 test adb shell uiautomator runtest myTest.jar -c com.myTest.TestClass2 </code></pre> <p>You can also tell Jenkins to use bash by adding a shebang to the first line of your script</p> <pre><code>#!/bin/bash </code></pre>