使用Jenkins可以爲React Native應用程序實現Continuos Integration?我還沒有找到指導來做到這一點。如果還有其他解決方案,最好的解決方案是什麼?另外,對於iOS項目,Mac OS機器是強制性的?繼續與Jenkins集成React Native(iOS + Android)項目
回答
是的,這是完全可能的。您只需從命令行執行所有操作,而不是XCode或您選擇的IDE。在iOS的情況下,請查看react-native bundle
命令以創建JS軟件包,並編譯xcodebuild
和xcrun
以編譯本機代碼。在Android中,它更容易一些,因爲您擁有gradle assembleRelease
任務。在此之前,您必須運行npm install
以獲取所有依賴關係,但這應該大致如此。
至於iOS開發,不幸的是沒有辦法繞過它,你確實需要一臺OS X機器。
能否請您提供鏈接 –
不幸的是,在React Native網頁上沒有關於該主題的文檔,所以很難指出您到某個特定的地方。我個人使用[fastlane](https://fastlane.tools/),並遵循非常標準的配置。 – martinarroyo
martinarroyo是否還有其他我可以遵循的文檔或腳本示例? – Jan
第一件事就是讓命令行構建適用於Android和iOS。您可以在Xcode或Android Studio日誌中達到最高點並複製一些命令。
我在ios和android文件夾中放置了一個build.sh腳本,我可以從Jenkins作業調用它來構建相應的目標。您可以在調用兩者的項目根目錄中擁有build.sh。
TODO:我想弄清楚如何在詹金斯的工作運行eslint的Airbnb和生成報告?
這裏是我的iOS BUILD.sh中,與Xcode的9作品:
#!/bin/sh
############################################
# File: build.sh
# -----------------------
# Author: [email protected]
#
# Command line build:
# 1) clean
# 2) build
# 3) archive
# 4) export IPA
#
# http://shashikantjagtap.net/xcodebuild-deploy-ios-app-command-line/
# https://help.apple.com/itc/apploader/e3#/apdATD1E53-D1E1A1303-D1E53A1126
#
isInPath=$(which xcodebuild)
if [ ! -x "${isInPath}" ] ; then
echo "*** Error xcodebuild not found in path"
exit 1
fi
isInPath=$(which xcrun)
if [ ! -x "${isInPath}" ] ; then
echo "*** Error xcrun not found in path"
exit 1
fi
echo "### Start: Cleaning ###############################################################"
rm -rf build
xcodebuild -project MyApp.xcodeproj -scheme MyApp -destination generic/platform=iOS clean
echo "### Done: Cleaning ###############################################################"
# Analyze
# xcodebuild -project MyApp.xcodeproj -scheme MyApp -sdk iphoneos clean analyze
echo "### Start: Building ###############################################################"
# xcodebuild -project MyApp.xcodeproj -target MyApp -showBuildSettings
# xcodebuild -project MyApp.xcodeproj -scheme MyApp -destination generic/platform=iOS build
# Run pod install once before building workspace
pod install
# Now using a Podfile so have to build workspace not build project
xcodebuild -workspace MyApp.xcworkspace -scheme MyApp -destination generic/platform=iOS build
echo "### Done: Building ###############################################################"
CFBundleShortVersionString=`/usr/libexec/PlistBuddy -c "Print :CFBundleShortVersionString" ./MyApp/Info.plist`
CFBundleVersion=`/usr/libexec/PlistBuddy -c "Print :CFBundleVersion" ./MyApp/Info.plist`
echo "CFBundleShortVersionString: ${CFBundleShortVersionString}"
echo "CFBundleVersion: ${CFBundleVersion}"
ipaFileName=MyApp.ipa
renameIpaFileName="field-scout-${CFBundleShortVersionString}.${CFBundleVersion}.ipa"
echo "### Start: Archiving ###############################################################"
# xcodebuild -project MyApp.xcodeproj -scheme MyApp -sdk iphoneos -configuration AppStoreDistribution archive -archivePath $PWD/build/MyApp.xcarchive
# Now using a Podfile so have to build workspace not build project
xcodebuild -workspace MyApp.xcworkspace -scheme MyApp -sdk iphoneos -configuration AppStoreDistribution archive -archivePath $PWD/build/MyApp.xcarchive
echo "### Done: Archiving ###############################################################"
echo "### Start: Exporting ###############################################################"
xcodebuild -exportArchive -archivePath $PWD/build/MyApp.xcarchive -exportOptionsPlist MyApp/ExportOptions.plist -exportPath $PWD/build
ls -al build
echo "### Done: Exporting ###############################################################"
appArchiveFile=build/${ipaFileName}
if [ ! -f "${appArchiveFile}" ]; then
echo "*** Error file not found: ${appArchiveFile}"
exit 1
fi
# Extract and verify archive contents
echo "### Unzip: ${ipaFileName} ###############################################################"
(cd build; unzip -q ${ipaFileName})
(cd build/Payload; xcrun codesign -dv MyApp.app/)
outputFile=build/Payload/MyApp.app
if [ ! -d "${outputFile}" ]; then
echo "*** Error file not found: ${outputFile}"
exit 1
fi
rm -rf ./build/Payload
rm -rf ./build/Symbols
# altool is used to verify iOS IPA files
altool_path=/Applications/Xcode.app/Contents/Applications/Application\ Loader.app/Contents/Frameworks/ITunesSoftwareService.framework/Versions/Current/Support
isInPath=$(which altool)
if [ ! -x "${isInPath}" ] ; then
echo "*** Error altool not found in path"
echo "Expected altool path:\n ${altool_path}"
exit 1
fi
# altool validate will trigger a user dialog first time it is run.
# On a jenkins slave you will need to execute manually in a console once, to allow keychain access.
# $ altool --validate-app -f file -u username [-p password] [--output-format xml]
# $ altool --upload-app -f file -u username [-p password] [--output-format xml]
altool --validate-app -f build/${ipaFileName} -u [email protected] -p @keychain:"Application Loader: [email protected]"
altool --validate-app -f build/${ipaFileName} -u [email protected] -p @keychain:"Application Loader: [email protected]" --output-format xml > build/validate.xml
altoolValidate=$?
if [ ${altoolValidate} -ne 0 ]; then
echo "*** Error IPA failed to validate: build/${ipaFileName}"
echo "See: build/validate.xml"
exit 1
fi
echo "Rename build/${ipaFileName} to build/${renameIpaFileName}"
mv ./build/${ipaFileName} ./build/${renameIpaFileName}
echo ##############################
echo Done
echo ##############################
echo Ready to upload archive to iTunes:
echo " ${appArchiveFile}"
echo
uploadExample="$(echo altool --upload-app -f build/${renameIpaFileName} -u [email protected] -p @keychain:"Application Loader: [email protected]")"
echo "Upload Example:\n ${uploadExample}"
echo
測試我們在Jenkinsfile有這樣的: 'builderNode {// TODO:創紀錄的業績 階段( 「測試」){ SH「泊塢窗運行--rm -i '$ {imageName}'紗線測試「 } }' – Cole
- 1. 將Android項目集成到React Native中
- 2. 與React Native的持續集成
- 3. 在現有的React Native iOS項目中安裝React-Native Android?
- 4. iOS - 與Jenkins/Fastlane持續集成
- 5. 如何在使用Podfiles集成react-native時集成react-native-video?
- 6. JSApplicationIllegalArgumentException與React Native Android
- 7. React Native iOS
- 8. 如何生成React Native項目的apk或ios文件
- 9. 如何在React Native項目中重新生成ios文件夾?
- 10. iOS與Jenkins,Hockey的持續集成並增加版本
- 11. React Native只是重新初始化iOS或Android項目
- 12. 使用android studio持續集成jenkins
- 13. React Native與現有Android應用程序集成閃回
- 14. 如何將這個lib /組件集成到我的react-native android項目中?
- 15. React-native:新項目問題
- 16. React-Native Mobx刪除項目
- 17. React-Native更新AsyncStorage項目
- 18. Jenkins與Github集成
- 19. React-Native android:調試選項?
- 20. React Native與Socket.io
- 21. React Native,AwesomeProject,react-native run-ios:** BUILD FAILED **
- 22. Jenkins與Artifactory集成
- 23. Jenkins與Grunt集成
- 24. DevOps繼續交付項目成員
- 25. HipChat與Jenkins集成
- 26. React-native,繼續在後臺下載進程
- 27. 如何將SocketMobile與React Native應用程序集成?
- 28. iOS繼續完成任務
- 29. 繼續集成中的部署方法 - Jenkins
- 30. React Native Android&Genymotion
哎,運氣好的話搞清楚了這一點?目前正試圖做同樣的事情。 – justColbs