jenkins 的安装及配置就不多做说明,网上有很多文章,下面我就直接讲下jenkins的脚本方面的配置
1、General
1.1配置node节点1.2条件配置 1.3初始化配置
PROVISIONING_PROFILE=7edaec8f-d369-44dc-a9e6-ccsdfasdfasd
CERTIFICATE_SHA1=3601A705E779sdfasdfasdfasdfasdf
NOTIFY_LIST= fu-min.qi@company.com
APP_NAME=test
APP_FILE_NAME=test
PROJ_NAME=test
APP_VER=2.1
PROJ_FILE_PATH=test-test/iOS/test
SETTINGS_PATH=test-test/iOS/test/Base.lproj
PREPROCESSOR_DEFINITIONS =ENTINVENTORY_IN_HOUSE
BUNDLE_ID=com.company.test
RELEASE_DISPLAYNAME=App Name
WORKSPACENAME=$JOB_NAME
BUILD_NUMBER=$BUILD_ID
XCODE_VERSION=8.2.1
2、Source Code Management
2.1拉取最新代码3、 Build Environment
WechatIMG159.jpeg 3.1打印配置项删除ipa和app文件,修改Info.plist文件
3.2删除ipa和app文件
echo @
echo @ Build Step: Assigning Version Strings...
echo @ VERSION_STRING = ${VERSION_STRING}
echo @
#
# Delete any existing .IPA files. We have found that xcode does not always update
# the contents of the IPA/APP files when files change
#
find ../$WORKSPACENAME/OneSource-EAM -type f -name "*.ipa" -exec rm -f {} \;
find ../$WORKSPACENAME/OneSource-EAM -type f -name "*.app" -exec rm -f {} \;
修改info.plist
#
# Special processing for EAM project that produces inventory app
#
echo @ Update build number
chmod a+rw "../${WORKSPACENAME}/OneSource-EAM/iOS/EAMInventory/info.plist"
/usr/libexec/PlistBuddy -c "Print" "../${WORKSPACENAME}/OneSource-EAM/iOS/EAMInventory/info.plist"
/usr/libexec/PlistBuddy -c "Set CFBundleVersion ${APP_VER}.${BUILD_NUMBER}" "../${WORKSPACENAME}/OneSource-EAM/iOS/EAMInventory/info.plist"
/usr/libexec/PlistBuddy -c "Print" "../${WORKSPACENAME}/OneSource-EAM/iOS/EAMInventory/info.plist"
#if [ "${BUILD_TYPE}" = "Release" ]
#then
#echo $BUNDLE_ID
#/usr/libexec/PlistBuddy -c "Set CFBundleIdentifier ${BUNDLE_ID}" "../${WORKSPACENAME}/OneSource-EAM/iOS/EAMInventory/info.plist"
#/usr/libexec/PlistBuddy -c "Set CFBundleDisplayName ${RELEASE_DISPLAYNAME}" "../${WORKSPACENAME}/OneSource-EAM/iOS/EAMInventory/info.plist"
#/usr/libexec/PlistBuddy -c "Print" "../${WORKSPACENAME}/OneSource-EAM/iOS/EAMInventory/info.plist"
# echo $BUNDLE_ID
#else
# /usr/libexec/PlistBuddy -c "Print" "../${WORKSPACENAME}/OneSource-EAM/iOS/EAMInventory/info.plist"
#fi
// 配置React Native
3.3 配置React Native
echo @
echo @ Build Step: Install npm Package...
echo @
cd ../${WORKSPACENAME}/OneSource-EAM/ReactNative/
rm -dfr node_modules
rm -dfr build
export PATH=$PATH:/usr/local/bin
mkdir build
npm install
#npm install react-native-safe-area-view --save
cp -af ../iOS/Pods/Local/RCTNativeAnimatedNodesManager.h node_modules/react-native/Libraries/NativeAnimation/RCTNativeAnimatedNodesManager.h
echo @
echo @
echo @ Build Step: Bundling RN Code...
echo @
react-native bundle --entry-file index.ios.js --platform ios --bundle-output build/main.jsbundle --sourcemap-output build/main.jsbundle.map --assets-dest build/ --dev false
4、 获取keychain
4.1 获取keychain5 、build option
5.1 build option6 、打包生成ipa
6.1 打包生成ipaecho @
echo @ Build Step: Signing Application
echo @
#export CODESIGN_ALLOCATE="/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/codesign_allocate"
xcodebuild -exportArchive -archivePath ./build/test.xcarchive -exportPath ./testIpa -exportOptionsPlist ../2.1-Build/OneSource-EAM/iOS/test/archive.beta.plist
echo $PATH
cd ../${WORKSPACENAME}/testIpa
if [ "${BUILD_TYPE}" = "Release" ]
then
echo @
echo @ Build Step: Signing Application For Production
echo @
echo $PATH
echo ${APP_FILE_NAME}.ipa
unzip -qo ${APP_FILE_NAME}.ipa
rm -rf /Users/builder/workspace/EAM-iOS-2.1-Build/testIpa/Payload/test.app/_CodeSignature
cp /Users/builder/workspace/EAM-iOS-2.1-Build/testIpa/embedded.mobileprovision /Users/builder/workspace/EAM-iOS-2.1-Build/testIpa/Payload/test.app/embedded.mobileprovision
security cms -D -i /Users/builder/workspace/EAM-iOS-2.1-Build/testIpa/embedded.mobileprovision > /Users/builder/workspace/EAM-iOS-2.1-Build/testIpa/Payload/test.app/entitlement_full.plist
#/usr/libexec/PlistBuddy -x -c 'Print Entitlements' /Users/builder/workspace/EAM-iOS-2.1-Build/testIpa/Payload/test.app/entitlements_full.plist > /Users/builder/workspace/EAM-iOS-2.1-Build/testIpa/Payload/test.app/Entitlements.plist
cp /Users/builder/workspace/EAM-iOS-2.1-Build/testIpa/entitlements.plist /Users/builder/workspace/EAM-iOS-2.1-Build/testIpa/Payload/test.app
/usr/libexec/PlistBuddy -c "Set CFBundleIdentifier com.company.entInventory" /Users/builder/workspace/EAM-iOS-2.1-Build/testIpa/Payload/test.app/Info.plist
/usr/libexec/PlistBuddy -c "Set CFBundleDisplayName OS EAM" /Users/builder/workspace/EAM-iOS-2.1-Build/testIpa/Payload/test.app/Info.plist
rm -f ${APP_FILE_NAME}.ipa
/usr/bin/codesign --continue -f -s "iPhone Distribution: company Informatics, Inc" --entitlements /Users/builder/workspace/EAM-iOS-2.1-Build/testIpa/Payload/test.app/entitlements.plist /Users/builder/workspace/EAM-iOS-2.1-Build/testIpa/Payload/test.app
zip -qr "${APP_FILE_NAME}.ipa" Payload
rm -rf /Users/builder/workspace/EAM-iOS-2.1-Build/testIpa/Payload
#open ./iOSAppSigner.app --wait-apps --args -ipa /Users/builder/workspace/EAM-iOS-2.1-Build/testIpa/${APP_FILE_NAME}.ipa -ipaout /Users/builder/workspace/EAM-iOS-2.1-Build/testIpa/${APP_FILE_NAME}-resigned.ipa -cert 'iPhone Distribution: company Informatics, Inc' -profileloc '/Users/builder/Library/MobileDevice/Provisioning Profiles/6dc5d947.mobileprovision' -newAppId 'com.company.entIn' -appName 'app name'
#rm -f ${APP_FILE_NAME}.ipa
#mv "${APP_FILE_NAME}-resigned.ipa" "${APP_FILE_NAME}.ipa"
else
echo ${BUILD_TYPE}
fi
echo @
echo @ Build Step: Publishing Artifacts...
echo @
#
# rename the new IPA file using the version string
#
mv "${APP_FILE_NAME}.ipa" "../${VERSION_STRING}.ipa"
#
上述打包使用的是先打包beta版本ipa,然后解包,重签名生成release环境的ipa,关于重签名的步骤在https://www.jianshu.com/p/f27211ae9ca9文章中有详细介绍,这里没有使用iOSAppSigner.app是因为
export CODESIGN_ALLOCATE="/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/codesign_allocate"
导致CODESIGN_ALLOCATE路径不对,将上述命令注销即可使用iOSAppSigner.app,正确的路径为
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/codesign_allocate
// 此路径在jenkins运行的时候有打印,可全局搜索一下,这里不用重新设置
在使用iOSAppSigner.app工具的时候,该工具签名完成是不会自动退出的,所以可以打开iOSAppSigner.app修改代码,让其签名完成自动退出,以上为jenkins打包的主要过程
网友评论