持续集成之jenkins

2022-06-30 13:47:38 浏览数 (1)

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

1、创建用户

useradd -d /usr/jenkins -m jenkins

passw 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

<Server port="9005"shutdown="SHUTDOWN" debug="0">

<Connector port="9080"protocol="HTTP/1.1" maxThreads="150"

connectionTimeout="20000" redirectPort="8443" />

<Connector port="9009"enableLookups="false" redirectPort="8443"debug="0"

protocol="AJP/1.3"/>

4、配置Jenkins的主目录

用root用户登录

编辑profile文件:vi /etc/profile

代码语言:javascript复制
   添加:export JENKINS_HOME=/usr/jenkins/jenkinsData
代码语言:javascript复制
保存退出后执行: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、点击

,后出现如下界面

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

exportPATH=PATH:ANDROID_HOME/tools:

source /etc/profile

更新sdk

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

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

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

代码语言:javascript复制
更新 Android SDK Build-tools版本:android update sdk -u --all --filter1,2,3,5,11,12,22,23,24,25,26,27,28,29,88,89

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

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

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

ANDROID_HOME

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

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

21、配置

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

创建文件autoStartup.sh

#!/bin/sh

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

exportCLASSPATH=CLASSPATH:JAVA_HOME/lib/tools.jar:

export PATH=PATH:JAVA_HOME/bin

exportCATALINA_HOME=/usr/local/jenkins/tomcat-jenkins-8.5

/usr/local/jenkins/tomcat-jenkins-8.5/bin/catalina.shstart

修改文件/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 thefollowing SDK components: [Android SDK Build-Tools 24.0.2]

http://majing.io/questions/804

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

问题解决

license存放在$ANDROID_HOME/licenses下

创建license

Linux

mkdir "

(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 objectfile: 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

0 人点赞