jenkins配置android自动打包平台

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/qq_35440678/article/details/80865977

目的

采用jenkins,关联git,自动拉取最新代码,自动打包Android apk包,一方面解放开发打包慢的问题,另一方面方便测试打包回归,节省人力。
整个搭建过程遇到比较多小问题,后面都一一解决,本文做个记录。

搭建流程

这里写图片描述

配置java环境

这个略过

gradle安装

apt install gradle

下载sdkmanager

https://developer.android.com/studio/#downloads

android sdk安装

./sdkmanager –list

android sdk安装

./sdkmanager “platform-tools” “platforms;android-26” “build-tools;27.0.3” “ndk-bundle”

jenkins配置 ANDROID_HOME

其他博客文章有

licences同意

安装过程提示licenses没有同意,找到一个解决方案。

解决方案:https://stackoverflow.com/questions/38096225/automatically-accept-all-sdk-licences
yes | sdkmanager –licenses

root@iZuf68ausnohve9zzvan1lZ:~/.jenkins/workspace/android-autobuild# ./gradlew 

> Configure project :MPChartLib 
File /root/.android/repositories.cfg could not be loaded.
Checking the license for package Android SDK Platform 27 in /data/android-sdk/licenses
Warning: License for package Android SDK Platform 27 not accepted.
Checking the license for package Android SDK Platform 27 in /data/android-sdk/licenses
Warning: License for package Android SDK Platform 27 not accepted.
Project evaluation failed including an error in afterEvaluate {}. Run with --stacktrace for details of the afterEvaluate {} error.


FAILURE: Build failed with an exception.

* Where:
Build file '/root/.jenkins/workspace/android-autobuild/MPChartLib/build.gradle' line: 61

* What went wrong:
A problem occurred evaluating project ':MPChartLib'.
> Failed to install the following Android SDK packages as some licences have not been accepted.
     platforms;android-27 Android SDK Platform 27
  To build this project, accept the SDK license agreements and install the missing components using the Android Studio SDK Manager.
  Alternatively, to transfer the license agreements from one workstation to another, see http://d.android.com/r/studio-ui/export-licenses.html

  Using Android SDK: /data/android-sdk

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 2s

编译包

./gradlew tasks
./gradlew assembleDebug

编译测试包

./gradlew assembleDebug –stacktrace

版本号自动递增

每次自动打包,版本号自动递增,实现:

http://devdeeds.com/auto-increment-build-number-using-gradle-in-android/

猜你喜欢

转载自blog.csdn.net/qq_35440678/article/details/80865977