老的打包方式
- 耗时时间长
- cpu满载,无法干别的事情
- 打包后还需要手动上传分发平台,无法自动化
Jenkins自动化打包
- 单独分配一个配置高的mac用于打包,耗时短
- 打包机的运行不影响开发者的工作
- 简单配置一些api可以自动化实现后续一系列流程
安装配置Jenkins
Jenkins安装
- Jenkins安装 需要java环境
brew install jenkins
- 安装完成后运行 jenkins
jenkins
2025-02-25 08:41:01.654+0000 [id=57] INFO jenkins.InitReactorRunner$1#onAttained: Completed initialization
2025-02-25 08:41:01.670+0000 [id=40] INFO hudson.lifecycle.Lifecycle#onReady: Jenkins is fully up and running
- 等待安装完成后打开http://localhost:8080
3.1 输入密码 3.2 安装推荐插件
3.3 创建账号
3.4 配置URL
3.5 安装完成
插件安装
Jenkins提供了一个插件管理中心,提供了很多有用的插件,许多功能是依靠插件完成的
- 选择Manage Jenkins
- 选择 Plugins
- 需要安装的插件
| 名称 | 作用 |
|---|---|
| git parameter | 设置git参数 |
| Xcode integration | 打ipa包 |
| build description | 构建描述 |
| build user vars plugin | 用来描述用户信息的 |
| update to pgyer | 上传蒲公英 |
| post build task | 完成所有任务后执行,通知飞书群 |
打包配置
- 全局环境变量
echo $PATH
- 新建任务
- 源码配置
- 创建凭证获取
ssh_key
cat .ssh/id_rsa.pub
5. 配置参数
6. build Steps 添加xcode
6.1 执行shell获取信息
rm -f pro.txt
touch pro.txt
plistPath=${WORKSPACE}/ChatTa/Info.plist
APPVERSION=`xcodebuild -project ChatTa.xcodeproj -showBuildSettings | grep "MARKETING_VERSION" | sed 's/[ ]*MARKETING_VERSION = //'`
APPBUILD=`xcodebuild -project ChatTa.xcodeproj -showBuildSettings | grep "CURRENT_PROJECT_VERSION" | sed 's/[ ]*CURRENT_PROJECT_VERSION = //'`
DisplayName=$(/usr/libexec/PlistBuddy -c "Print :CFBundleDisplayName" ${plistPath})
if [ -n "${Version}" ]; then
APPVERSION=${Version}
fi
echo "APPVERSION=${APPVERSION}" > pro.txt
echo "APPBUILD=${APPBUILD}" >> pro.txt
echo "DisplayName=${DisplayName}" >> pro.txt
${WORKSPACE}/Script/checkout_yidui.sh $branch
if [ ${SubModuleChoice} == 'branch' ]; then
${WORKSPACE}/Script/submodule_update.sh
else
${WORKSPACE}/Script/submodule_update.sh ${SubModuleChoice}
fi
#判断是否存在测试信息写入脚本 不存在则不执行
if [ -f "./Script/test_input.py" ]; then
python3 ./Script/test_input.py ${JOB_NAME} ${BUILD_ID} ${BUILD_USER} ${branch}
fi
6.2 一些配置
- 配置
Code signing & OS X keychain options - 配置
Advanced Xcode build options - 配置
Versioning
构建后操作
- 归档、 上传蒲公英
- 飞书