# 关闭selinux
setenforce 0
sed -i '/=enforcing/s/enforcing/disabled/g' /etc/sysconfig/selinux
# 关闭防火墙
service iptables stop && chkconfig iptables off
引用:https://blog.csdn.net/H12KJGJ/article/details/79240984
Java的历史版本:http://www.oracle.com/technetwork/java/javase/archive-139210.html
我们选择java8:http://www.oracle.com/technetwork/java/javase/downloads/java-archive-javase8-2177648.html
需要oracle的账号,请自行注册
# rpm -ivh jdk-8u172-linux-x64.rpm
# java -version
引用大神资源:https://blog.csdn.net/hanfengzqh/article/details/78184851
[root@Jenkins ~]# wget http://mirrors.flysnow.org/gradle/gradle-3.1-all.zip
[root@Jenkins ~]# unzip gradle-3.1-all.zip
[root@Jenkins ~]# vim /etc/profile
GRADLE_HOME=/root/soft/gradle-3.1
PATH=${PATH}:${GRADLE_HOME}/bin
记得export
:wq
[root@Jenkins ~]# source /etc/profile
[root@Jenkins ~]# gradle -v
------------------------------------------------------------
Gradle 3.1
------------------------------------------------------------
Build time: 2016-09-19 10:53:53 UTC
Revision: 13f38ba699afd86d7cdc4ed8fd7dd3960c0b1f97
Groovy: 2.4.7
Ant: Apache Ant(TM) version 1.9.6 compiled on June 29 2015
JVM: 1.8.0_172 (Oracle Corporation 25.172-b11)
OS: Linux 2.6.32-696.el6.x86_64 amd64
[root@Jenkins ~]# wget -O /etc/yum.repos.d/jenkins.repo https://pkg.jenkins.io/redhat-stable/jenkins.repo
[root@Jenkins ~]# vim /etc/yum.repos.d/jenkins.repo //关掉gpgcheck
[root@Jenkins ~]# yum install jenkins
[root@Jenkins ~]# vim /etc/sysconfig/Jenkins
29 JENKINS_USER="root" //防止权限冲突
56 JENKINS_PORT="8080" //默认端口8080
:wq
[root@Jenkins ~]# vim /etc/profile
export JENKINS_HOME=/var/lib/jenkins/
:wq
[root@Jenkins ~]# source /etc/profile
[root@Jenkins ~]# echo $JENKINS_HOME
/var/lib/jenkins/
[root@Jenkins ~]# service jenkins start
//这时候会发现/usr/lib/jenkins/下面就有了jenkins.war文件,无需wget从官网下载
[root@Jenkins ~]# cd /usr/lib/jenkins/
[root@Jenkins jenkins]# ll
总用量 73016
-rw-r--r--. 1 root root 74764818 8月 15 22:32 jenkins.war
[root@Jenkins ~]# vim /var/log/jenkins/jenkins.log
//查看jenkins的日志,最后一行显示Listed all plugins或者Jenkins is fully up and running表示jenkins服务正常运行中
打开浏览器,访问:http://x.x.x.x:8080
选择推荐安装,多一个不多嘛 - - 万一有天要用呢
分割线————————————————————————————————————————————————————————
环境:
Gitlab:192.168.1.111
Jenkins:192.168.1.112
Git服务器称为A、Jenkins称为B这样子
两台机器相同操作开启RSA认证
vim /etc/ssh/sshd_config
47 RSAAuthentication yes
48 PubkeyAuthentication yes
49 AuthorizedKeysFile .ssh/authorized_keys
:wq
service sshd restart
[root@Gitlab .ssh]# ssh-keygen //如果之前配置好过git的可以免了
[root@Gitlab .ssh]# scp /root/.ssh/id_rsa [email protected]:/root/.ssh/
# 把公钥添加到B服务器的authorized_keys
A服务器: cat id_rsa.pub
ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAuyoyNHXdiUHiV/CBD7rwcLDuLTYSgp1xKvo+Zycop734gYWyUVal8b/SAlWErZ7s8JCIwmxbeLWpyPKPRm9j919Va0eitc9H4JYBbZCd60apj+odH7MRcDYfSeJjJX513SeHIMNhUe+TT+ujm6X2gPkjpe/pq+gdbj+aRme33Ym+bgxtn7uQJQNANwrm4CdRtEcakbUwIOTczgGlIk5pAXA2xMZkJ/OnkZj2RI18Dk7pZEG0DH0FuGJ9nRuOFsoyybt5btKJMlIGIfhdJ0lhrDgllJiFoTuBczFp2cU3eth25/0OR9Wu2JRIdIKLmIT1EP5RCuernbmW2HRlcMUIAQ== [email protected]
B服务器: cat /root/.ssh/authorized_keys
ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAuyoyNHXdiUHiV/CBD7rwcLDuLTYSgp1xKvo+Zycop734gYWyUVal8b/SAlWErZ7s8JCIwmxbeLWpyPKPRm9j919Va0eitc9H4JYBbZCd60apj+odH7MRcDYfSeJjJX513SeHIMNhUe+TT+ujm6X2gPkjpe/pq+gdbj+aRme33Ym+bgxtn7uQJQNANwrm4CdRtEcakbUwIOTczgGlIk5pAXA2xMZkJ/OnkZj2RI18Dk7pZEG0DH0FuGJ9nRuOFsoyybt5btKJMlIGIfhdJ0lhrDgllJiFoTuBczFp2cU3eth25/0OR9Wu2JRIdIKLmIT1EP5RCuernbmW2HRlcMUIAQ== [email protected]
//必须一样!!!
A尝试登陆B
B尝试登陆A
提前核对下项目配置文件所需求的插件:
主要查看:buildToolsVersion,compileSdkVersion,compileOptions(Java版本)
//每个module目录都要自己查看
下载Android SDK 或者 通过AS安装SDK(需要图形化支持)
本次项目用的是命令行方式、
[root@Jenkins ~]# cd /root/soft/
[root@Jenkins ~]# wget http://dl.google.com/android/android-sdk_r24.4.1-linux.tgz
[root@Jenkins ~]# tar -xf android-sdk_r24.4.1-linux.tgz
[root@Jenkins ~]# cd android-sdk-linux/tools/
[root@Jenkins ~]# ./android update sdk --no-ui //更新SDK
[root@Jenkins ~]# vim /etc/profile
ANDROID_HOME=/root/soft/android-sdk-linux
GRADLE_HOME=/root/soft/gradle-3.1
PATH=${PATH}:${GRADLE_HOME}/bin:$ANDROID_HOME/tools
export ANDROID_HOME GRADLE_HOME PATH USER LOGNAME MAIL HOSTNAME HISTSIZE HISTCONTROL
export JENKINS_HOME=/var/lib/jenkins/
:wq
[root@Jenkins ~]# source /etc/profile
[root@Jenkins ~]# android list sdk --all //查看可用组件
# 下载需要的组件, 注意--all 这个参数一定要加上, 否则后面filter里的序号不起作用
例如我用的是
android update sdk -u --all -filter 1,2,6,47
//当构建时报错是缺少插件的, 即可到这里获取(有条件update全部,去掉-filter选项)
yum install git 在再”全局工具配置”配置下
git和svn就跳过了,直接来实用的:
java.io.IOException: Cannot run program "gradle"
//检查aapt文件是存在的,原因是centos下缺少C++的语言库
yum install gcc gcc-c++
Error: java.util.concurrent.ExecutionException: java.lang.RuntimeException: No server to serve request. Check logs for details.
查看aapt 是否工作正常
提示需要GLIBC_2.14版本
[root@Jenkins soft]# wget http://ftp.gnu.org/gnu/glibc/glibc-2.14.tar.gz //下载
glibc升级:https://blog.csdn.net/ai2000ai/article/details/78983461
升级后cannot change locale (zh_CN.UTF-8): No such file or directory:
这是因为升级了glibc的原因
解决方法:
[root@Jenkins ~]# vim /etc/sysconfig/i18n
LANG="zh_CN.utf8"
LC_ALL=C
export LC_ALL
:wq
[root@Jenkins ~]# source /etc/sysconfig/i18n
重新登录即可
先去蒲公英官网注册一个账号,实名认证过后,获取到API及user的KEY
构建 --> 执行shell中 添加
curl -F "file=@这里是你的APK文件位置" -F "uKey=蒲公英的key" -F "_api_key=蒲公英的api_KEY" https://www.pgyer.com/apiv1/app/upload