我正在尝试使用Jenkins和Fastlane构建iOS应用程序。Jenkins的master是一台Linux机器,slave是一台macOS机器,两者都运行在AWS上。
项目存储库托管在Gitlab.
当管道通过Jenkins运行时,它会给出以下错误:
以下构建命令失败:compilesswift normal arm64合作设计/用户/ec2-user/图书馆/开发/Xcode/DerivedData/AssociatedPress-fccudiwnsqoxlobymusvrmoonnxe/构建/中间体。noindex/ArchiveIntermediates/AssociatedPress/IntermediateBuildFilesPath/UninstalledProducts/iphoneos/AssociatedPress Notification Extension.appex
我的fasyfile的内容是:
node('macos') {
{
stage('Checkout') {
checkout scm
}
stage('Resolve packages') {
sh 'bash resolvePackages'
}
stage('Build Store') {
sh 'fastlane store'
}
}
}
Fastfile如下:-
default_platform :ios
platform :ios do
desc "Build Store"
lane :store do
gym(workspace: "AssociatedPress.xcworkspace",
scheme: "AssociatedPress",
clean: true,
output_directory: "./fastlane/Store",
archive_path: "./fastlane/Store/AssociatedPressStore.xcarchive",
buildlog_path: "./fastlane/Store/build_log",
export_method: "app-store",
export_options: {
provisioningProfiles: {
"com.apnews.ipad.mobilenewsdevel" => "AP News Store",
"com.apnews.ipad.mobilenewsdevel.watchkitapp" => "AP News WatchApp Store",
"com.apnews.ipad.mobilenewsdevel.watchkitapp.watchkitextension" => "AP News WatchExtension Store",
"com.apnews.ipad.mobilenewsdevel.notificationextension" => "AP News Notification Store",
},
uploadBitcode: false,
compileBitcode: false
})
end
end
构建只有在通过Jenkins运行时才会在CodeSign上失败。当fastlane命令在macOS从节点上本地运行时,构建成功。
版本:-
- macOS: 11.5.1
- xocde版本:12.5.1
- fastlane: 2.192.0
我已经尝试了一些解决方案,如在健身前解锁钥匙链,运行set-key-partition-list命令,都没有解决问题。
遇到同样错误的人,我们发现iOS不允许您通过SSH访问密钥链。由于Jenkins主节点使用SSH访问Jenkins从节点,访问keychain被拒绝导致CodeSign错误。
在花了将近一个星期的时间试图解决这个问题后,我们转向Gitlab CI/CD而不是Jenkins,并实现了我们的目标。