CI实践_Android持续集成

  1. 云栖社区>
  2. 博客>
  3. 正文

CI实践_Android持续集成

ghost丶桃子 2016-05-20 16:43:22 浏览1940
展开阅读全文

之前已经实现了Android的持续集成,并在项目中应用了一段时间。恰逢现在有几分钟时间,把之前的一些零散的点滴记录和整理一下,供有需要的朋友参考,或后续复用。

需要的准备知识:gitlab、Jenkins、各种plugins、shell等;

另外,推荐一个seafiles,相当于云存储网盘,大家可以把构建的apk包,发送至,供团队内部使用;

当然,你也可以采用ftp为team共享也可以。

 

一.总体的全局配置:

配置相关plugin,如果需要进行代码检测的话,也需要安装Sonar,部分配置如下:

Sonar installations:

Name :sonar

Server URL:http://192.168.0.100:9000/

Sonar account login:admin

Sonar account password:*****

Database URL:jdbc:mysql://localhost:3306/sonar?useUnicode=true&characterEncoding=utf8&rewriteBatchedStatements=true

Database login:root

Database password:****

 

邮件通知
     SMTP服务器        smtp.exmail.qq.com        
     用户默认邮件后缀    @aituyou.com

 

二.单个Project中的配置:

触发构建器:

Build after other projects are built

Projects to watch:TSD-Common

 

源码管理:

Git Repositories: http://121.201.13.32:9000/xiaobao/tsd-navigation.git

 

Build periodically:日程表

# H 9-17/2 * * 1-5

Pull SCM:

# H 9-16/2 * * 1-5

Command Shell:

复制代码
echo `pwd`
echo "buld start time:`date`"
echo '******************* Start build *************************'
##cd /var/lib/jenkins/;./env.sh
cd /var/lib/jenkins/jobs/TSD-Nav/workspace/
#### dos2unix files
dos2unix `find . -name "*.java"` 

/opt/Android/adt-bundle-linux-x86_64-20140624/sdk/tools/android update project -t 3 -p . -n TSD-Nav
sed -i '$d' project.properties
sed -i '$d' project.properties
sed -i '$a target=android-19' project.properties
sed -i '$a android.library.reference.1=../../TSD-Common/workspace/' project.properties
#sed -i '$a android.library.reference.1=../../TSD-Thirdparty/workspace/qiniu-sdk/' project.properties

# change key
sed -i 's/r1Em7hxaGvUmbu3Te5Mne508/0TC6r2T1uTX9xgdUSyQuV5Lo/g' /var/lib/jenkins/jobs/TSD-Nav/workspace/AndroidManifest.xml

/opt/ANT/apache-ant-1.9.4/bin/ant clean
/opt/ANT/apache-ant-1.9.4/bin/ant debug
/opt/ANT/apache-ant-1.9.4/bin/ant release

# signer
#jarsigner -verbose -keystore /home/tuyou/HAO/TuYouDemoKeyStore -signedjar /var/lib/jenkins/jobs/TSD-Nav/workspace/bin/TSD-Nav-release-signed.apk /var/lib/jenkins/jobs/TSD-Nav/workspace/bin/TSD-Nav-release-unsigned.apk 'tuxiaobao' -storepass 'tuxiaobao'
jarsigner -verbose -sigalg MD5withRSA -digestalg SHA1 -keystore /home/tuyou/HAO/tuyou_android.keystore -signedjar /var/lib/jenkins/jobs/TSD-Nav/workspace/bin/TSD-Nav-release-signed.apk /var/lib/jenkins/jobs/TSD-Nav/workspace/bin/TSD-Nav-release-unsigned.apk tuyou_android.keystore -storepass 'tuxiaobao'

# get version number
#HAO = `cat AndroidManifest.xml | grep versionName= | awk -F "=" '{print $2}' |awk -F "\"" '{print $2}'`
#echo ${HAO}
#cd /var/lib/jenkins/jobs/TSD-Nav/workspace/bin
#mv TSD-Nav-debug.apk TSD-Nav-+${HAO}.apk
#ls -la
#cd /var/lib/jenkins/jobs/TSD-Nav/workspace/

#get date
# date -d now +%Y%m%d%H%M%S


cd /var/lib/jenkins/jobs/TSD-Nav/workspace/bin
#mv TSD-Nav-debug.apk TSD-Nav-`cat /var/lib/jenkins/jobs/TSD-Nav/workspace/AndroidManifest.xml | grep versionName= | awk -F "=" '{print $2}' |awk -F "\"" '{print $2}'`.apk
mv TSD-Nav-release-signed.apk TSD-Nav-Release-`cat /var/lib/jenkins/jobs/TSD-Nav/workspace/AndroidManifest.xml | grep versionName= | awk -F "=" '{print $2}' |awk -F "\"" '{print $2}'`-`date -d now +%Y%m%d%H%M%S`.apk
cd /var/lib/jenkins/jobs/TSD-Nav/workspace/


#FTP directory :/var/ftp/anonymous/upload
cp /var/lib/jenkins/jobs/TSD-Nav/workspace/bin/TSD-Nav-Re*.apk /var/ftp/anonymous/upload/tsd-app-Release/Nav/

#copy to seafiles
cp /var/lib/jenkins/jobs/TSD-Nav/workspace/bin/TSD-Nav-Re*.apk /home/tuyou/Seafile/Seafile/发布/AutoBuild
echo '******************* Finish build *************************'
echo "buld end time:`date`"
复制代码

 

其实没有过多解释,如果需要了解细节的朋友,可以联系我。

 

转载请注明出处:http://www.cnblogs.com/haochuang/ 8年IT工作经验,5年测试技术与管理,2年产品与项目管理,曾参与过云计算\云存储\车联网产品研发工作; 业余自媒体人,有技术类垂直微信公众号;如有招聘或求职方面需求,请Mail to uetest@qq.com ;或通过 QQ:363573922 微博:@念槐聚 联系;

网友评论

登录后评论
0/500
评论