ios - Jenkins + iOS + TestFlight API

标签 ios jenkins jenkins-plugins xcodebuild testflight

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

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

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

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

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

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

最佳答案

这是我正在使用的脚本。 (很明显我删除了个人信息,但你应该没问题)。

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

关于ios - Jenkins + iOS + TestFlight API,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16798139/

相关文章:

ios - 如何从以前删除的应用程序访问新应用程序中的本地数据

bash - Jenkins Groovy : how to extract specific number from parameter in method?

jenkins - 如何知道 Jenkins 作业的运行时间

git - Jenkins Git Publisher、多个 repo 和多个 SCM

ios - Xcode 7 : Cannot add Push Notification entitlement under Capabilities

html - 在iOS中使UIWebview的字体加粗

ios - 警告 : Unbalanced calls to begin/end appearance transitions for QLRemotePreviewContentController

jenkins - 在 Windows 构建命令之间保留 Jenkins 中的环境变量

python - 通过 jenkins UI 编辑工作区文件

jenkins - 获取所有 secret 并将其放入 Jenkins 和 hashicorp 保险库的 env 文件中