Jenkins持续集成安卓

https://www.digitalocean.com/community/tutorials/how-to-build-android-apps-with-jenkins

1、创建用户useradd -d /usr/jenkins -m jenkinspassw jenkins密码:jenkins

2、下载安装jdk8.0

vi /usr/jenkins/.bash_profile

export JAVA_HOME=/usr/jenkins/jdk1.8.0_121

export PATH=$JAVA_HOME/bin:$PATH

source /usr/jenkins/.bash_profile

3、下载安装tomcat8.0下载tomcat:

wget http://mirrors.hust.edu.cn/apache/tomcat/tomcat-8/v8.5.14/bin/apache-tomcat-8.5.14.tar.gz 

解压:tar -xzvf apache-tomcat-8.5.14.tar.gz

重命名目录:mv apache-tomcat-8.5.14 tomcat-jenkins-8.5

修改端口:vi server.xml

 

protocol="AJP/1.3"/>

4、配置Jenkins的主目录

用root用户登录

编辑profile文件:vi /etc/profile

  添加:export JENKINS_HOME=/usr/jenkins/jenkinsData

保存退出后执行:source /etc/profile

5、下载并安装Jenkins

  http://mirrors.jenkins-ci.org/war-stable/

wget http://mirrors.jenkins-ci.org/war-stable/2.46.1/jenkins.war

把jenkins.war放到tomcat的webapps目录

启动tomcat

6、在浏览器输入http://61.147.171.62:9080/jenkins,出现如下图


7、在目录/usr/jenkins/jenkinsData/secrets/initialAdminPassword获取密码并输入步骤6的文本框中

cat /usr/jenkins/jenkinsData/secrets/initialAdminPassword

点击按钮Continue,出现如下界面


8、点击 "select plugins to install",后出现如下界面


9、点击 后None,界面变化如下图,然后点击Install


10、安装完毕后出现如下图


11、创建用户,然后点击"save and finish"

用户名:admin

密码:admin

12、安装成功后


13、登录jenkins


14、安装插件:系统管理==》插件管理==》可选插件


15、需要安装的插件

Subversion

Gradle Plugin

Subversion Release Manager plugin

Android Emulator Plugin


16、下载gradle并安装,配置gradle

wget https://services.gradle.org/distributions/gradle-3.5-bin.zip

unzip gradle-3.5-bin.zip

vi /etc/profile

export GRADLE_HOME=/usr/jenkins/gradle-3.5

export PATH=$PATH:$GRADLE_HOME/bin

source /etc/profile

17、下载安装android SDK,并配置

wget https://dl.google.com/android/android-sdk_r24.4.1-linux.tgz

tar -zxvf android-sdk_r24.4.1-linux.tgz

vi /etc/profile

export ANDROID_HOME=/usr/jenkins/android-sdk-linux

export PATH=$PATH:$ANDROID_HOME/tools:$ANDROID_HOME/platform-tools

source /etc/profile

更新sdk

全部更新:android update sdk --no-ui

部分更新:android update sdk -u --filter platform-tools,android-25

获取 Android SDK Build-tools版本,获取序号:android list sdk --all

更新 Android SDK Build-tools版本:android update sdk -u --all --filter 1,2,3,5,11,12,22,23,24,25,26,27,28,29,88,89

修改目录权限:chmod -R 755 /usr/jenkins/android-sdk-linux

install_android_sdk脚本:

tools/android list sdk --all | grep -vi obsolete|grep -E 'Android (Support|((SDK (Tools|Platform-tools|Build-tools))))|SDK Platform Android'|awk '{gsub("-","");print $1}'|xargs|tr ' ' ','

18、配置jenkins:系统管理==》Global Tool Configuration,并点击 保存"save"


19、设置全局变量: 系统管理==》系统设置

ANDROID_HOME


20、创建:新建==》构建一个自由风格的软件项目

输入一个名字,然后点击OK按钮


21、配置




22、修改tomcat内存大小,开启自启动

创建文件autoStartup.sh

#!/bin/sh

export JAVA_HOME=/usr/local/jenkins/jdk1.8.0_121

export CLASSPATH=$CLASSPATH:$JAVA_HOME/lib/tools.jar:$JAVA_HOME/lib/dt.jar:.

export PATH=$PATH:$JAVA_HOME/bin

export CATALINA_HOME=/usr/local/jenkins/tomcat-jenkins-8.5

/usr/local/jenkins/tomcat-jenkins-8.5/bin/catalina.sh start

修改文件/etc/rc.d/rc.local,添加如下内容

/usr/local/jenkins/tomcat-jenkins-8.5/bin/autoStartup.sh

23、出现的问题

(a)https://my.oschina.net/zhangxu0512/blog/262275

(b)http://www.cnblogs.com/274914765qq/p/4440248.html

(c)Gradle提示:You have not accepted the license agreements of the following SDK components: [Android SDK Build-Tools 24.0.2]

http://majing.io/questions/804

有什么办法自动接受所有的license呢?

问题解决

license存放在$ANDROID_HOME/licenses下

创建license

Linux

mkdir "$ANDROID_HOME/licenses"echo -e "\n8933bad161af4178b1185d1a37fbf41ea5269c55" > "$ANDROID_HOME/licenses/android-sdk-license"

(d)/lib/ld-linux.so.2: bad ELF interpreter问题:

http://www.111cn.net/sys/linux/55374.htm

yum install glibc.i686

(e)android-sdks/build-tools/17.0.0/aapt: error while loading shared libraries: libz.so.1: cannot open shared object file: No such file or directory

http://stackoverflow.com/questions/17020298/android-sdks-build-tools-17-0-0-aapt-error-while-loading-shared-libraries-libz/21505268

yum install zlib.i686 libstdc++.i686


你可能感兴趣的:(Jenkins持续集成安卓)