Jenkins
2021-05-15 本文已影响0人
你飞跃俊杰
一、安装
1.下载jenkins.war
下载地址 : https://www.jenkins.io/zh/download/
2.解压jenkins.war包
java -jar /Users/你飞跃俊杰/Desktop/jenkins/jenkins.war --httpPort=8080
3.下载java
下载地址 :http://java.com
4.启动
java -jar jenkins.war
5.下载插件
下载git
安装git
安装Xcode-common-line
安装Xcode
安装java
配置国内库源
可设置语言
jenkins中文社区 community.jenkins-zh.cn
6.打包
cd /Users/galaxyx/.jenkins/workspace/test
#xxx是工程名
if [ ! -d ./IPADir ];
then
mkdir -p IPADir;
fi
security unlock-keychain -p "1234" ~/Library/Keychains/login.keychain
#工程绝对路径
project_path=~/Documents/company_prj/package
#工程名 将XXX替换成自己的工程名
project_name=GalaxyX
#scheme名 将aaa替换成自己的sheme名
scheme_name='GalaxyX-Uat'
#打包模式 Debug/Release
development_mode=Experience
#build文件夹路径
build_path=${project_path}/build
#plist文件所在路径
exportOptionsPlistPath=${project_path}/GalaxyX.plist
#导出.ipa文件所在路径
exportIpaPath=${project_path}/ipa/${development_mode}
echo "Place enter the number you want to export ? [ 1:app-store 2:ad-hoc] "
##
#read number
#while([[ $number != 1 ]] && [[ $number != 2 ]])
#do
#echo "Error! Should enter 1 or 2"
#echo "Place enter the number you want to export ? [ 1:app-store 2:ad-hoc] "
#read number
#done
if [ $number == 1 ];then
development_mode=Experience
exportOptionsPlistPath=${project_path}/exportTest.plist
else
development_mode=Experience
exportOptionsPlistPath=${project_path}/exportTest.plist
fi
echo '///-----------'
echo '/// 正在清理工程'
echo '///-----------'
#xcodebuild \
#clean -configuration ${development_mode} -quiet || exit
xcodebuild -workspace /Users/galaxyx/.jenkins/workspace/test/GalaxyX.xcworkspace -scheme GalaxyX -configuration Release clean
echo '///--------'
echo '/// 清理完成'
echo '///--------'
echo ''
echo '///-----------'
echo '/// 正在编译工程:'${development_mode}
echo '///-----------'
xcodebuild \
archive -workspace /Users/galaxyx/.jenkins/workspace/test/${project_name}.xcworkspace \
-scheme ${scheme_name} \
-configuration ${development_mode} \
-archivePath ${build_path}/${project_name}.xcarchive -quiet || exit
echo '///--------'
echo '/// 编译完成'
echo '///--------'
echo ''
echo '///----------'
echo '/// 开始ipa打包'
echo '///----------'
xcodebuild -exportArchive -archivePath ${build_path}/${project_name}.xcarchive \
-configuration ${development_mode} \
-exportPath ${exportIpaPath} \
-exportOptionsPlist ${exportOptionsPlistPath} \
-quiet || exit
if [ -e $exportIpaPath/$scheme_name.ipa ]; then
echo '///----------'
echo '/// ipa包已导出'
echo '///----------'
open $exportIpaPath
else
echo '///-------------'
echo '/// ipa包导出失败 '
echo '///-------------'
fi
echo '///------------'
echo '/// 打包ipa完成 '
echo '///-----------='
echo ''
echo "开始上传到蒲公英"
#上传到蒲公英
#蒲公英aipKey
MY_PGY_API_K=xxxxxxxxxxxxxxxx
#蒲公英uKey
MY_PGY_UK=xxxxxxxxxxx
curl -F "file=@${exportIpaPath}/${scheme_name}.ipa" -F "uKey=${MY_PGY_UK}" -F "_api_key=${MY_PGY_API_K}" pgyer.com/apiv1/app/upload
w3cschool.cn/jenkins/
community.jenkins-zh.cn