【问题标题】:Jenkins + iOS + TestFlight API詹金斯 + iOS + TestFlight API
【发布时间】:2013-05-28 17:35:05
【问题描述】:

我安装了 Jenkins 并使用 Git 插件、Xcode 插件和 Testflight 插件启动了一个项目。

我可以使用设置创建自动构建,但在为 Testflight 创建 .ipa 文件时失败。

问题在于调试和发布设置以不同的方式...

如果我尝试通过 Debug 设置创建 .ipa,它将在没有 build/Debug-iphoneos 文件夹的情况下失败(我尝试关闭 clean 选项,但没有帮助)。但是 Xcode Build 在命令行上并没有失败

当我尝试切换到 Release 时,链接器失败 (ld)。

如果没有 .ipa 文件,我无法提交到 Testflight 并获得自动测试分发。

【问题讨论】:

  • 您用来构建它的脚本/命令在哪里?您的 .ipa 路径可能是错误的。

标签: ios jenkins jenkins-plugins xcodebuild testflight


【解决方案1】:

这是我正在使用的脚本。 (明明我把个人信息删了,不过你应该能理解)。

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

【讨论】:

  • 感谢脚本。但它再次失败,因为链接器没有找到 ld: library not found for -lPods Pods 的东西......
  • jenkins 服务器上是否安装了 cocoapods?
  • 是的,我发现了我这边的失败。我需要在 xcodebuild 命令行中使用 Scheme 和 Workspace
  • Testflight 插件已弃用。现在有没有其他方法可以做到这一点,纯粹通过詹金斯? stackoverflow.com/q/57289366/1364053
  • 是的,我正在研究它,最后的结论是 Jenkins 本身无法上传到 tesflight。所以我必须使用另一个服务,比如 fastlane。
【解决方案2】:

我认为您的构建所针对的方案不正确。

此外,TestFlight 有一个plugin for Jenkins,因此您可以编写构建过程的脚本并使用他们的 Jenkins 插件执行上传到 TestFlight。我通过手动命令行和 Jenkins CI 提供了一个适合我的构建脚本示例。

如果您想查看完整设置,可以在此处找到 iOS/Git/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

【讨论】:

猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2018-06-19
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多