React Native Jenkins 自动化打包

react

这是最近做的RN项目 jenkins 自动化打包成功实现

构建

    Execute shell  (脚本如下)

env

#/usr/bin/security default-keychain -d user -s /Users/ett/Library/Keychains/login.keychain

#/usr/bin/security unlock-keychain -p * /Users/ett/Library/Keychains/login.keychain


export ETT_APP_NAME=kmOnline

export ETT_WORKSPACE_NAME=ETTMallWork

export ETT_PROJECT_NAME=ETTMallWork

export ETT_SCHEME=ETTMallWork

export ETT_PROVISIONING_PROFILE=kmOnlineTestAdhotProfile

export ETT_BUILD_TYPE=.SNAPSHOT

export ETT_CONFIGURATION=Release

###############################################################################################################

#rm -rf  node_modules

#npm cache verify

#mkdir node_modules

cp -r /Users/ett/Desktop/kumeng/node_modules   $WORKSPACE

npm install

react-native bundle --entry-file index.js --bundle-output ./ios/main.jsbundle --platform ios

cd $WORKSPACE/ios

export ETT_JENKINS_TIME=$(date +%m%d)

export ETT_GIT_COMMIT=${GIT_COMMIT:0:7}

export ETT_GIT_REV=`git rev-list HEAD | wc -l | awk '{print $1}'`

export ETT_VERSION_PRO=`/usr/bin/agvtool mvers -terse1`

export ETT_VERSION_NUMBER=$ETT_VERSION_PRO$ETT_BUILD_TYPE

export ETT_BUILD_VERSION=$ETT_GIT_REV.$BUILD_NUMBER

export ETT_BUILD_ID=$ETT_VERSION_NUMBER-$ETT_JENKINS_TIME-$ETT_GIT_REV-$BUILD_NUMBER-G$ETT_GIT_COMMIT

export NEXUS_JENKINS_NAME=jenkins

export NEXUS_JENKINS_PASSWD=jenkins20100328

#adhoc_export_plist

export ExportOptionsPlistPath=/Users/ett/Desktop/kmOnlineProfile/adhoc_export_plist/ExportOptions.plist

export XCODE=/usr/bin

export ETT_DIST_ROOT_PATH=/Users/ett/Documents/Developer/jenkins-dist/$JOB_NAME

export ETT_DIST_PATH=$ETT_DIST_ROOT_PATH/$BUILD_NUMBER

export ETT_ARCHIVE_PATH=$ETT_DIST_PATH/$ETT_APP_NAME.xcarchive

export ETT_WORK_SPACE=$WORKSPACE/$ETT_WORKSPACE_NAME.xcworkspace

export ETT_PROJECT_SPACE=$WORKSPACE/ios/$ETT_PROJECT_NAME.xcodeproj

export ETT_FILE_NAME=$ETT_APP_NAME-$ETT_BUILD_ID

export ETT_IPA_NAME=$ETT_FILE_NAME.ipa

export ETT_EXPORT_PATH=$ETT_DIST_PATH/$ETT_IPA_NAME

export ETT_PACKAGE_NAME=$ETT_FILE_NAME.tar.gz

export ETT_PACKAGE_PATH=$ETT_DIST_PATH/$ETT_PACKAGE_NAME

export ETT_NEXUS_FILE_NAME=$ETT_APP_NAME-$ETT_JENKINS_TIME-$BUILD_NUMBER-$ETT_GIT_COMMIT.tar.gz

export ETT_UPLOAD_DSYM_SRC=$ETT_WORKSPACE_NAME.app.dSYM

export ETT_UPLOAD_DSYM_FILE=$ETT_FILE_NAME-dSYM.zip

export ETT_UPLOAD_DSYM_PATH=$ETT_DIST_PATH/$ETT_UPLOAD_DSYM_FILE

if [ ! -d "$ETT_DIST_ROOT_PATH" ]; then

  mkdir $ETT_DIST_ROOT_PATH

fi

if [ ! -d "$ETT_DIST_PATH" ]; then

  mkdir $ETT_DIST_PATH

fi

#/usr/bin/agvtool vers -terse

#/usr/bin/agvtool mvers -terse1

/usr/bin/agvtool new-marketing-version $ETT_VERSION_PRO

/usr/bin/agvtool new-version -all $ETT_VERSION_PRO.$ETT_BUILD_VERSION

xcodebuild   \

clean -project $ETT_PROJECT_SPACE \

-scheme $ETT_SCHEME \

-configuration $ETT_CONFIGURATION

xcodebuild  \

archive   \

-project $ETT_PROJECT_SPACE \

-scheme $ETT_SCHEME \

-configuration $ETT_CONFIGURATION \

-archivePath $ETT_ARCHIVE_PATH \

-sdk iphoneos11.2

xcodebuild  \

-exportArchive -archivePath  $ETT_ARCHIVE_PATH  \

-exportPath $ETT_EXPORT_PATH      \

-exportOptionsPlist $ExportOptionsPlistPath


#$XCODE/xcodebuild clean build BITCODE_GENERATION_MODE=bitcode OTHER_CFLAGS="-fembed-bitcode" archive -archivePath $ETT_ARCHIVE_PATH -project $ETT_PROJECT_SPACE -destination generic/platform=iOS -scheme $ETT_SCHEME -configuration $ETT_CONFIGURATION -sdk iphoneos11.2

#$XCODE/xcodebuild -exportArchive -archivePath $ETT_ARCHIVE_PATH -exportPath $ETT_EXPORT_PATH -exportOptionsPlist $ExportOptionsPlistPath -allowProvisioningUpdates

备注:常见错误

1.-sdk iphoneos11.2  因为打包服务器 版本落后于开发机器上的版本,所以要加入 此项参数

查看命令:xcodebuild -showsdks

2.因为项目里的第三方库 不支持 Bitcode 打包方式

所以

3.证书配置问题:

   不知道证书和描述文件具体名称或者没有plist文件 可以在手动导出ipa 文件里找到

以上是 React Native Jenkins 自动化打包 的全部内容, 来源链接: utcz.com/z/383115.html

回到顶部