前一篇:Jenkins九:Jenkins打包时同时生成企业ipa服务器下载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节点
依次点击:
Manage Jenkins
-> Manage Nodes
参考:
-
jenkins上新增一个Mac的slave-agent
在Slave机器上进行如下配置
然后点击左侧的新建节点
配置如下
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"
#***************动态配置部分*********************
#平台名称及SVN文件夹名称#Target名称#发布证书所有者
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"
#这里创建和修改ExportOptions
echo "+++++++++++++++++export ipa+++++++++++++++++"
#生成xxx.ipa
xcodebuild -exportArchive \
-archivePath "${ArchivePath}" \
-exportPath "${IPAFolderPath}" \
-exportOptionsPlist ${myOptionsPlist}
##读取打包后的内容的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}"
#如果没有文件夹,则创建文件夹
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命令行上传单个文件到服务器
参考:
上传命令:
#防止报编码的错误
export LC_ALL=en_US.UTF-8
export LANG=en_US.UTF-8
export LANGUAGE=en_US.UTF-8
svn import 本地文件或目录 远程服务端目录 --username '用户名' --password '密码' -m '添加描述(可为空)'
例子:将本地的test.txt文件上传到svn服务器上,一定要精确到文件上,不要上传空文件夹
svn import ./test.txt https://192.168.x.xxx:xxx/xx/xxx/test.txt -m "测试添加文件"
下载命令:
svn export 远程服务端文件或目录 本地路径(可为空,则下载到当前位置) --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.](https://www.jianshu.com/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