直接入正題:
Mac上安裝Jekins
jekins下載地址:http://jenkins-ci.org/ ,選擇Mac 直接安裝。安裝成功后。訪問http://localhost 是否可正常訪問.
安裝Jekins相關插件
xcode插件
2.https://wiki.jenkins-ci.org/display/JENKINS/XCode+Plugin#XcodePlugin-Installationguide
腳本執行插件
3.https://wiki.jenkins-ci.org/display/JENKINS/PostBuildScript+Plugin
git插件
4.https://wiki.jenkins-ci.org/display/JENKINS/Git+Plugin
IOS證書管理和修正
1.點擊 Manage Jenkins-> [Keychains and Provisioning Profiles Management] 進入如下頁面
2.點擊choose File 并上傳 當前登錄用戶的~/Library/Keychain/login.keychain文件.
上傳成功后會出現:
點擊Add Code Signing Identity添加對應的簽名
3.上傳Provisioning Profiles文件,xcode的profile存放在~/Library/MobileDevice/Provisioning Profiles/中,找到你要的profile,上傳
這步很重要,如果證書出錯請查看:http://www.cnblogs.com/qingjoin/p/3929493.html
新建項目
1.New Item -> 選擇FreeStyle project
2.關聯GIt
3.Xcode的相關配置
4.ipa上傳到蒲公英和發送郵件
5.相關的python文件的地址為:
https://github.com/caiwenshu/CI_pgy/blob/master/pgy_upload_temp.py
該代碼引用來自:http://www.cocoachina.com/ios/20150428/11698.html
最新補充 (2020/02/19)
因為jenkins里面xcode配置麻煩,現在已經把ios的打包移植到fastlane里面了。
source ~/.bash_profile
export LC_ALL=en_US.UTF-8
export LANG=en_US.UTF-8
echo $WORKSPACE
export output_dir=/Users/Shared/Jenkins/${BUILD_TAG}
export output_ipa_name=${BUILD_TAG}.ipa
echo $output_dir
echo $output_ipa_name
rm -rf release
ruby -v
bundle install
pwd
security unlock-keychain -p shenmajr /Users/macpro/Library/Keychains/login.keychain-db
fastlane release output_dir:$output_dir output_ipa_name:$output_ipa_name
對應的fastlane代碼
# This file contains the fastlane.tools configuration
# You can find the documentation at https://docs.fastlane.tools
#
# For a list of all available actions, check out
#
# https://docs.fastlane.tools/actions
#
# For a list of all available plugins, check out
#
# https://docs.fastlane.tools/plugins/available-plugins
#
# Uncomment the line if you want fastlane to automatically update itself
# update_fastlane
default_platform(:ios)
platform :ios do
desc "Description of what the lane does"
lane :release do |options|
cocoapods
gym(scheme: "ShenmaEV_iOS_SaaS",
workspace:"ShenmaEV_iOS_SaaS.xcworkspace",
configuration:"Release",
clean: true,
export_method:"enterprise",
output_directory:options[:output_dir],
buildlog_path:options[:output_dir],
output_name:options[:output_ipa_name])
# add actions here: https://docs.fastlane.tools/actions
end
lane :debug do |options|
cocoapods
gym(scheme: "ShenmaEV_iOS_SaaS",
workspace:"ShenmaEV_iOS_SaaS.xcworkspace",
configuration:"Debug",
clean: true,
export_method:"development",
output_directory:options[:output_dir],
buildlog_path:options[:output_dir],
output_name:options[:output_ipa_name])
# add actions here: https://docs.fastlane.tools/actions
end
end