标签:
之前已经实现了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/p/4766491.html