jenkins shell命令打包
jenkins的环境搭建和配置就不说了,直接上iOS项目管理搭建
1 jenkins项目创建
1.jpg2 自定义环境参数
2.1 自定义环境参数在xcode里的配置
通过jenkins选择的参数选择对应的环境
3.jpg 4.jpg3 git管理
4 重点shell构建 (重点)
此shell为cd到项目路径下 更新pod每次打包必走此shell
6.jpg5 打包shell (重点)
7.jpg6 更新pod的shell脚本
#bin/bsah - l
export LANG=en_US.UTF-8
export LANGUAGE=en_US.UTF-8
export LC_ALL=en_US.UTF-8
cd $WORKSPACE/TuiKe
/usr/local/bin/pod install --verbose --no-repo-update
cd $WORKSPACE/TuiKe/Resource/Json
echo "{\"environmentType\":\"$environmentType\",\"isEncrypt\":\"$isEncrypt\"}" > jenkinsCofig.json
7 打包shell脚本
#工程名字(Target名字)
Project_Name="工程名字"
#xcode的Bundle ID
AdHocBundleID="com.xxx"
#配置环境,Release或者Debug
Configuration="Release"
#加载各个版本的plist文件
# adhoc打包出来的plist文件在哪里,这里放到了工程目录最外面./
ADHOCExportOptionsPlist=./ADHOCExportOptionsPlist.plist
ADHOCExportOptionsPlist=${ADHOCExportOptionsPlist}
#adhoc证书 在钥匙串里查看复制adhoc证书的名字如:iPhone Distribution:InvestmentManagement Co., Ltd. (123ABCDEFG)
ADHOCCODE_SIGN_IDENTITY="iPhone Distributionxxxxx"
#adhoc配置文件 前往~/Library/MobileDevice/Provisioning Profiles查看
ADHOCPROVISIONING_PROFILE_NAME="e17e2c5a-54c6-430f-a60d-28e33798614f"
#当前目录
SORCEPATH=${WORKSPACE}
#plist路径
SCHEME_INFO_PLIST_PATH="${SORCEPATH}/${Project_Name}/Other/Info.plist"
build_path=${SORCEPATH}/build
#删除bulid目录
if [ -d ${build_path} ];then
rm -rf ${build_path}
echo clean build_path success.
fi
#adhoc脚本
xcodebuild -workspace $Project_Name.xcworkspace -scheme $Project_Name -configuration $Configuration -archivePath build/$Project_Name-adhoc.xcarchive clean
xcodebuild archive -workspace $Project_Name.xcworkspace -scheme $Project_Name -configuration $Configuration -archivePath build/$Project_Name-adhoc.xcarchive CODE_SIGN_IDENTITY="${ADHOCCODE_SIGN_IDENTITY}" PROVISIONING_PROFILE="${ADHOCPROVISIONING_PROFILE_NAME}" PRODUCT_BUNDLE_IDENTIFIER="${AdHocBundleID}"
xcodebuild -exportArchive -archivePath build/$Project_Name-adhoc.xcarchive -exportOptionsPlist $ADHOCExportOptionsPlist -destination generic/platform=iOS -exportPath build/$Project_Name-adhoc.ipa
#获取版本号
BUNDLESHORTVERSION=`xcodebuild -showBuildSettings | grep MARKETING_VERSION | tr -d 'MARKETING_VERSION ='`
#build号
#VERSION=$(defaults read "${SCHEME_INFO_PLIST_PATH}"CFBundleVersion)
#时间
BUILD_DATE="$(date +'%Y%m%d_%H:%M')"
#ipa名字 项目名字_V版本号_时间
IPANAME="${Project_Name}_V${BUNDLESHORTVERSION}_${BUILD_DATE}.ipa"
#老的ipa路径 打包出来会自动生成的名字为Project_Name.ipa 这里进行替换.ipa名字格式为Project_Name_V1.0.0_20200124_14_12.ipa 方便查看打包时间
OLD_IPA_PATH="${SORCEPATH}/build/$Project_Name-adhoc.ipa/$Project_Name.ipa"
#新的ipa路径
NEW_IPA_PATH="${SORCEPATH}/build/$Project_Name-adhoc.ipa/$IPANAME"
#拷贝
#cp $OLD_IPA_PATH $NEW_IPA_PATH
#rm $OLD_IPA_PATH
mv $OLD_IPA_PATH $NEW_IPA_PATH
网友评论