2013-05-28 206 views
0

我安裝了Jenkins並使用Gi​​t插件,Xcode插件和Testflight插件啓動了一個項目。Jenkins + iOS + TestFlight API

我可以使用安裝程序創建自動構建版本,但它在創建Testflight的.ipa文件時失敗。

的問題是在調試和釋放,雖然不同的方式設置...

如果我試圖創建的.ipa通過調試設置將在沒有建立/調試-的iPhoneOS夾點失敗(我試圖打開乾淨的選項,但沒有幫助)。但是Xcode Build並沒有在命令行失敗

當我嘗試切換到釋放鏈接器失敗(ld)。

沒有.ipa文件我無法提交給Testflight並獲得自動化測試分發。

+0

哪裏是您使用來構建它的腳本/命令?您的.ipa路徑可能是錯誤的。 –

回答

2

這是我正在使用的腳本。 (顯然我刪除了個人信息,但你應該很好理解它)。

TARGET_NAME="-"  # Target name 
TARGET_SDK="iphoneos"     # Target SDK: iphoneos 
CONFIGURATION="Release"  # Build Configuration 
BUILD_DIR="build"      # Directory where the build is generated 
ARCHS="armv7"       # Valid Architectures 
APP_NAME="-"    # Application name 

## Provisioning configurations 
BUILD_ARCHIVED_DIR="BuildArchived"     # Directory with the history of builds 
DEVELOPER_NAME="-" # Developer name 
PROVISIONING_PROFILE=Prototype.mobileprovision  # Provisioning profile file 
PROVISIONING_DIR=~/Library/MobileDevice/Provisioning\ Profiles/      # Provisioning dir 

## TestFlight App 
TESTFLIGHT_API_TOKEN="-"  
TESTFLIGHT_TEAM_TOKEN="-" 


#Release Notes 
BUILDSCRIPTS_DIR="build" 
TESTFLIGHT_RELEASE_NOTES_FILE="ios_testflight-releasenotes" 


#Distribution Lists 
TESTFLIGHT_DISTRIBUTION_LISTS="Jenkins" 


# Returns to the root directory of the build 
cd ../ios 

PROJECT_BUILDDIR="${BUILD_DIR}/${CONFIGURATION}-${TARGET_SDK}" 
CURRENT_DIR=`pwd` 

# fix for the newest sdk 
# Only export the environment variable if the location exists, 
# otherwise it breaks the signing process! 
if [ -f "/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/codesign_allocate" ] 
then 
    echo Export environment variable for codesign_allocate location 
    export CODESIGN_ALLOCATE=/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/codesign_allocate 
fi 


#changing the build version 
INFO_PLIST_PATH="${CURRENT_DIR}/${TARGET_NAME}/${TARGET_NAME}-Info.plist" 
/usr/libexec/PlistBuddy -c "Set :CFBundleVersion ${SVN_REVISION}" $INFO_PLIST_PATH 


# compile project 
echo Building Project 
xcodebuild -target "${TARGET_NAME}" -sdk "${TARGET_SDK}" ARCHS=${ARCHS} -configuration "${CONFIGURATION}" clean build 

#Check if build succeeded 
#if [ $? != 0 ] 
#then 
# exit 1 
#fi 

# Create output dir ($x) if doesn't exist 
mkdir -p $BUILD_ARCHIVED_DIR 

# .ipa file generation 
echo Generating .ipa file 
/usr/bin/xcrun -sdk "${TARGET_SDK}" PackageApplication -v  "${PROJECT_BUILDDIR}/${APP_NAME}.app" -o  "${CURRENT_DIR}/${BUILD_ARCHIVED_DIR}/${APP_NAME}.ipa" --sign "${DEVELOPER_NAME}" 

#zipping the .dSYM to send to Testflight 
echo Generating zip file 
/usr/bin/zip -r "${CURRENT_DIR}/${BUILD_ARCHIVED_DIR}/${APP_NAME}.app.dSYM.zip" "${CURRENT_DIR}/${PROJECT_BUILDDIR}/${APP_NAME}.app.dSYM" 

echo Sending to TestFlight 
curl http://testflightapp.com/api/builds.json -F file="@${CURRENT_DIR}/${BUILD_ARCHIVED_DIR}/${APP_NAME}.ipa" -F dsym="@${CURRENT_DIR}/${BUILD_ARCHIVED_DIR}/${APP_NAME}.app.dSYM.zip" -F api_token="${TESTFLIGHT_API_TOKEN}" -F team_token="${TESTFLIGHT_TEAM_TOKEN}" -F notes="This build was uploaded via the upload API" -F notify=False -F distribution_lists="${TESTFLIGHT_DISTRIBUTION_LISTS}" 
echo Submission ended 
+0

感謝您的腳本。但它再次失敗,因爲它沒有找到ld:找不到-lPods這個豆莢的鏈接器... – mariusLAN

+0

是在jenkins服務器上安裝的cocoapods? –

+0

是的,我發現我身邊的失敗。我需要在xcodebuild命令行中使用Scheme和Workspace – mariusLAN

0

我想象計劃您構建的目標是不正確。

此外,TestFlightplugin for Jenkins這樣你就可以編寫腳本的構建過程和執行使用它們詹金斯插件上傳到TestFlight。我已經提供了一個構建腳本示例,可以通過手動命令行和Jenkins CI爲我工作。

如果你想看到完整的安裝程序,你可以找到一個的iOS /混帳/ TestFlight教程這裏:Jenkins iOS – Git, xcodebuild, TestFlight

xcodebuild -alltargets clean 

rm -rf "./JenkinsBuild/*" 

xcodebuild -target HelloJenkins PROVISIONING_PROFILE="00000000-0000-0000-0000-000000000000" CONFIGURATION_BUILD_DIR=JenkinsBuild 

rm -rf "./JenkinsArchive/*" 

xcodebuild -scheme HelloJenkins archive PROVISIONING_PROFILE="00000000-0000-0000-0000-000000000000" CODE_SIGN_IDENTITY="iPhone Developer: Jonny Appleseed (XXXXXXXXXX)" -archivePath ./JenkinsArchive/HelloJenkins.xcarchive 

rm -rf "./JenkinsIPAExport/*" 

xcodebuild -exportArchive -exportFormat IPA -exportProvisioningProfile iOS\ Team\ Provisioning\ Profile:\ com.yourAPP.HelloJenkins -archivePath ./JenkinsArchive/HelloJenkins.xcarchive -exportPath ./JenkinsIPAExport/HelloJenkins.ipa