这几天稍稍研究了一下这些命令行,根据捕捉到的命令进行了整理,目前整合出了完全使用命令行来实现iOS的持续集成的方式,目前把相关的命令行代码分享一下,供大家参考:
#设置命令路径
WORKSPACE_PATH=`pwd`
SCAN_BUILD_PATH=~/dev-tools/clang/llvm/tools/clang/tools/scan-build/scan-build
CLANG_PATH=/usr/bin/clang
XCODEBUILD_PATH=/usr/bin/xcodebuild
XCRUN_PATH=/usr/bin/xcrun
#设置用户变量
#静态扫描第三方问题数目
ERROR_COUNT=0
#要打包的Target名称
APP_TARGET=
#单元测试的TestTarget名称
#APP_TEST_TARGET=
SIMULATOR_SDK=iphonesimulator6.0
OS_SDK=iphoneos6.0
#输入内测包所需的mobileprovision文件位置
MOBILEPROVISION_PATH=
#输入解锁登录证书的密码
PASSWORD=
cd${WORKSPACE_PATH}
#执行静态代码扫描
rm-rfscan.output
rm-rf${WORKSPACE_PATH}/clangScanBuildReports
${SCAN_BUILD_PATH}-k-v-v-o${WORKSPACE_PATH}/clangScanBuildReports--use-analyzer${CLANG_PATH}xcodebuild-target${APP_TARGET}-configurationDebug-sdk${SIMULATOR_SDK}cleanbuild|teescan.output
ACC_ERROR_COUNT=`grep-E^scan-build:bugsfoundscan.output|awk{print$2}`
#处理检查结果,如果扫描出的问题数目多于第三方问题总数表示本工程也存在问题,构建失败
if[${ACC_ERROR_COUNT}-gt${ERROR_COUNT}];then
echoscan-buildfound${ACC_ERROR_COUNT}bugs,largerthan${ERROR_COUNT}.Pleasecheck...
exit1
fi
#自定义脚本
#执行单元测试
#编译测试环境app
${XCODEBUILD_PATH}-target${APP_TARGET}-sdk${SIMULATOR_SDK}-configurationDebugcleanbuild
#自定义脚本
#解锁登录证书链
/usr/bin/securitylist-keychains-s${HOME}/Library/Keychains/login.keychain
/usr/bin/securitydefault-keychain-duser-s${HOME}/Library/Keychains/login.keychain
/usr/bin/securityunlock-keychain-p${PASSWORD}${HOME}/Library/Keychains/login.keychain
#编译线上环境app
${XCODEBUILD_PATH}-target${APP_TARGET}-sdk${OS_SDK}-configurationReleasecleanbuild
#构建ipa包
${XCRUN_PATH}-sdk${OS_SDK}PackageApplication-v${WORKSPACE_PATH}/build/Release-iphoneos/${APP_TARGET}.app-o${WORKSPACE_PATH}/build/Release-iphoneos/${APP_TARGET}-Release-RC.ipa--embed${MOBILEPROVISION_PATH}
#自定义脚本
目前在本地生活业务线已经进行了相关的测试,目前验证的结果显示和使用Xcode等插件的效果是一致的;