Jenkins Pipeline的Android模拟器
作者:互联网
寻找将在管道作业中模拟Android的Jenkins插件.
This plug-in在Freestyle工作中效果很好,但此时此时间为doesn’t support pipelines.
有没有办法通过Jenkins管道在Android上运行功能测试?
解决方法:
这是我的解决方案.希望能帮助到你.
node {
try{
def ANDROID_HOME='/opt/android-sdk-linux'
def ADB="$ANDROID_HOME/platform-tools/adb"
stage('Stage Checkout') {
git branch: 'develop', credentialsId: 'd9f13c8b-f917-4374-8849-2b9730885333', url: 'http://git.hostname.com/something.git'
}
stage('Stage Build') {
sh "./gradlew clean assembleRelease"
}
stage('Stage Unit Tests') {
sh "./gradlew testReleaseUnitTest"
}
stage('Stage Instumental Tests') {
sh "$ADB start-server"
def error
parallel (
launchEmulator: {
sh "$ANDROID_HOME/tools/qemu/linux-x86_64/qemu-system-x86_64 -engine classic -prop persist.sys.language=en -prop persist.sys.country=US -avd test -no-snapshot-load -no-snapshot-save -no-window"
},
runAndroidTests: {
timeout(time: 20, unit: 'SECONDS') {
sh "$ADB wait-for-device"
}
try {
sh "./gradlew :MyKet:connectedAndroidTest"
} catch(e) {
error = e
}
sh script: '/var/lib/jenkins/kill-emu.sh'
}
)
if (error != null) {
throw error
}
}
currentBuild.result = "SUCCESS"
} catch (e) {
currentBuild.result = "FAILED"
// notifyFailed()
throw e
} finally {
stage('Stage Clean') {
sh script: '/var/lib/jenkins/clean.sh'
}
}
}
标签:android,android-emulator,jenkins,jenkins-pipeline 来源: https://codeday.me/bug/20190623/1267560.html