前一篇:Jenkins九:Jenkins打包時同時生成企業(yè)ipa服務(wù)器下載plist
后一篇:Jenkins十一:一份代碼多個APP的多Target和單Target比較
參考如下:
- Mac下安裝Tomcat
-
Jenkins 主備master-slave模式搭建
tomcat安裝目錄:~/Library/Tomcat/bin
資源下載列表
jenkins下載頁面
jenkins War包下載頁面
http://mirrors.jenkins-ci.org/
1、將jenkins.war放入到安裝的tomcat的webapps路徑里
2、訪問:http://localhost:8080/jenkins進行jenkins的配置
3、jenkins安裝好后開始配置Master-Slave節(jié)點
依次點擊:
Manage Jenkins -> Manage Nodes

參考:
-
jenkins上新增一個Mac的slave-agent
在Slave機器上進行如下配置
tmp1b267051.png
然后點擊左側(cè)的新建節(jié)點

配置如下

Tips:
jenkins安裝幾個插件會比較好用:
Node and Label parameter
git parameter
遇到問題xcode-select: error: tool 'xcodebuild' requires Xcode
解決辦法:xcode-select: error: tool 'xcodebuild' requires Xcode
xcrun: error: unable to find utility "PackageApplication", not a developer tool or in PATH
解決方案:xcrun: error: unable to find utility "PackageApplication", not a developer tool or in PATH
完整腳本:
#xxx表示需要更加自己項目進行配置
# 工程名
APP_NAME="xxxx"
#***************動態(tài)配置部分*********************
#平臺名稱及SVN文件夾名稱#Target名稱#發(fā)布證書所有者
platform_scheme_sign_Array=(${platform_scheme_sign//\#/ })
# 平臺及SVN文件夾名稱
svnName=${platform_scheme_sign_Array[0]}
#target/scheme名稱
#SCHEMECA=${platform_scheme_sign_Array[1]}
SCHEMECA="OneNumberDev"
#code sign
#signName=${platform_scheme_sign##*#}
signName="iPhone Distribution: xxxx"
profile="xxxx"
#打包日期(年月日)
DATEOFDAY="$(date +%Y%m%d)"
#打包的時間(年月日-時分秒)
DATE="$(date +%Y%m%d-%H%M%S)"
Node_User="xxxx"
Node_Pwd="xxxx"
#*************************************
#下面2行是集成有Cocopods的用法
security unlock-keychain -p ${Node_Pwd} /Users/${Node_User}/Library/Keychains/login.keychain
echo "=================clean================="
xcodebuild -workspace "./${APP_NAME}.xcworkspace" -scheme ${SCHEMECA} -configuration 'Release' clean
echo "+++++++++++++++++archive+++++++++++++++++"
#生成的archive的位置
ArchivePath="./${SCHEMECA}_${DATE}.xcarchive"
xcodebuild archive \
-workspace "./${APP_NAME}.xcworkspace" \
-scheme ${SCHEMECA} \
-configuration Release \
-archivePath ${ArchivePath}
APPPath="${ArchivePath}/Products/Applications/${SCHEMECA}.app"
IPAFolderPath="${WORKSPACE}/${SCHEMECA}_${DATE}"
IPAPath="${WORKSPACE}/${SCHEMECA}_${DATE}.ipa"
echo "+++++++++++++++++create plist+++++++++++++++++"
myOptionsPlist="/Users/xxxx/jenkins_workspace/ExportOptions.plist"
#這里創(chuàng)建和修改ExportOptions
echo "+++++++++++++++++export ipa+++++++++++++++++"
#生成xxx.ipa
xcodebuild -exportArchive \
-archivePath "${ArchivePath}" \
-exportPath "${IPAFolderPath}" \
-exportOptionsPlist ${myOptionsPlist}
##讀取打包后的內(nèi)容的Info
InfoPath="${APPPath}/Info.plist"
#取build值
bundleVersion=$(/usr/libexec/PlistBuddy -c "print CFBundleShortVersionString" "${InfoPath}")
#取APP名稱
#打包代碼的分支
tagOrBranchName=${GIT_BRANCH_TAG/origin\//""}
#生成的唯一名稱
UNIQUE_NAME="${APP_NAME}_${SCHEMECA}_V${bundleVersion}_${tagOrBranchName}_${DATE}"
IPANAME="${UNIQUE_NAME}.ipa"
ParentSVNPath="./svn_${DATE}"
svnPath="${ParentSVNPath}/${svnName}/${DATEOFDAY}"
#如果沒有文件夾,則創(chuàng)建文件夾
if [ ! -d ${svnPath} ];then
mkdir -p ${svnPath}
fi
mv "${IPAFolderPath}/${SCHEMECA}.ipa" "${svnPath}/${IPANAME}"
#生成dSYM
dsymutil ${APPPath}/${SCHEMECA} -o "${svnPath}/${UNIQUE_NAME}.app.dSYM"
#刪除生成的文件
rm -rf ${ArchivePath}
rm -rf ${IPAFolderPath}
echo "+++++++++++++++++svn+++++++++++++++++"
export LC_ALL=en_US.UTF-8
export LANG=en_US.UTF-8
export LANGUAGE=en_US.UTF-8
svn import "${ParentSVNPath}/${svnName}/${DATEOFDAY}/${IPANAME}" \
"https://xxxx/xxx/xxx/${svnName}/${DATEOFDAY}/${IPANAME}" \
--username 'xxxx' \
--password 'xxxx' \
-m "測試添加文件"
svn import "${ParentSVNPath}/${svnName}/${DATEOFDAY}/${UNIQUE_NAME}.app.dSYM" \
"https://xxx.xxx.xx.xx/xxx/xxxx/${svnName}/${DATEOFDAY}/${UNIQUE_NAME}.app.dSYM" \
--username 'xxx' \
--password 'xxxx' \
-m "測試添加文件"
rm -rf ${ParentSVNPath}
SVN命令行上傳單個文件到服務(wù)器
參考:
上傳命令:
#防止報編碼的錯誤
export LC_ALL=en_US.UTF-8
export LANG=en_US.UTF-8
export LANGUAGE=en_US.UTF-8
svn import 本地文件或目錄 遠程服務(wù)端目錄 --username '用戶名' --password '密碼' -m '添加描述(可為空)'
例子:將本地的test.txt文件上傳到svn服務(wù)器上,一定要精確到文件上,不要上傳空文件夾
svn import ./test.txt https://192.168.x.xxx:xxx/xx/xxx/test.txt -m "測試添加文件"
下載命令:
svn export 遠程服務(wù)端文件或目錄 本地路徑(可為空,則下載到當前位置) --username '用戶名'
xcodebuild -archivePath "/Users/USERNAME/.jenkins/workspace/APPNAME/build/Debug-iphoneos/APPNAME.xcarchive" -project /Users/USERNAME/.jenkins/workspace/PROJECT NAME/APPNAME.xcodeproj -sdk iphoneos -scheme "SCHEMENAME" -configuration "Debug" archive
[Jenkins + Xcode9 打包報錯: requires a provisioning profile with the Push Notifications feature.](http://www.itdecent.cn/p/7d6ef618f5f4)
xcodebuild -exportArchive -archivePath "/Users/USERNAME/.jenkins/workspace/APPNAME/build/Debug-iphoneos/APPNAME.xcarchive" -exportPath "/Users/USERNAME/.jenkins/workspace/APPNAME/build/APPNAME_debug" -exportOptionsPlist '/Users/USERNAME/.jenkins/workspace/APPNAME/build/ExportOptions.plist' -allowProvisioningUpdates
