一、下载文件
1、下载apache http://tomcat.apache.org

双击解压后拖到Mac用户目录下

2、下载jenkins.war
https://jenkins.io/download/

拖入到Apache的webapps目录下(会自动解压)

3、终端运行
cd apache-tomcat-8.0.46/bin/
/Users/xxx/apache-tomcat-8.0.46/bin/startup.sh
注意:如果没有java环境需要安装java环境

.sh文件出现 Permission denied问题解决:
chmod 777 x.sh
二、配置
1、浏览器中输入:http://localhost:8080/jenkins/
注册用户后,进入主页面,点击新建
输入项目名后选择第一个,点击OK

2、填入SVN项目路径,添加SVN账户

(也可以构建本地项目,选中None,修改shell脚本)
3、安装Xcode插件


4、上传fir插件
下载fir插件http://blog.fir.im/jenkins/


5、配置Xcode(或用Xcode9 shell脚本替代Xcode配置)

Target就是项目里面的target,也是项目名称
.ipa filename pattern 就是ipa文件名
output directory 填入/Users/xxx/.jenkins/workspace/项目名称/ipa/

填入team ID,从钥匙串里能找到


scheme就是项目名称
workspace file填写/Users/xxx/.jenkins/workspace/项目名称/项目名称
project directory填写项目名称
project file 填写 /Users/xxx/.jenkins/workspace/项目名称/
build output directory /Users/xxx/.jenkins/workspace/项目名称/output

(用Xcode9 shell脚本替代Xcode配置)

粘贴并替换相关地方
xcodebuild -archivePath "/Users/xxx/.jenkins/workspace/项目名称/output/项目名称.xcarchive" -workspace 项目名称.xcworkspace -sdk iphoneos -scheme "项目名称" -configuration "Release" archive
xcodebuild -exportArchive -archivePath
"/Users/xxx/.jenkins/workspace/项目名称/output/项目名称.xcarchive" -exportPath "/Users/xxx/.jenkins/workspace/项目名称/ipa/项目名称.ipa" -exportOptionsPlist '/Users/xxx/.jenkins/workspace/项目名称/ipa/ExportOptions.plist' -allowProvisioningUpdates
(构建本地项目)
xcodebuild -archivePath "/Users/xxx/.jenkins/workspace/项目名称/output/项目名称.xcarchive" -workspace 项目名称.xcworkspace -sdk iphoneos -scheme "项目名称" -configuration "Release" archive
xcodebuild -exportArchive -archivePath
"/Users/xxx/.jenkins/workspace/项目名称/output/项目名称.xcarchive" -exportPath "/Users/xxx/.jenkins/workspace/项目名称/ipa/" -exportOptionsPlist '/Users/xxx/.jenkins/workspace/项目名称/ipa/ExportOptions.plist' -allowProvisioningUpdates
创建plist文件ExportOptions.plist并复制文件到/Users/xxx/.jenkins/workspace/项目名称/ipa
目录下
内容:替换bundleID、ad-hoc描述文件、teamID
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>compileBitcode</key>
<false/>
<key>method</key>
<string>ad-hoc</string>
<key>provisioningProfiles</key>
<dict>
<key>用BundleID替换</key>
<string>用ad-hoc描述文件名称替换</string>
</dict>
<key>signingCertificate</key>
<string>iPhone Distribution</string>
<key>signingStyle</key>
<string>manual</string>
<key>stripSwiftSymbols</key>
<true/>
<key>teamID</key>
<string>用teamID替换</string>
<key>thinning</key>
<string><none></string>
</dict>
</plist>
6、构建后上传到fir.im

填入fir.im token
填入ipa输入路径/Users/xxx/.jenkins/workspace/项目名称/ipa/

至此,保存构建!
下次启动时在终端运行/Users/xxx/apache-tomcat-8.0.46/bin/startup.sh
网友评论