通过 Jenkins 和 Fastlane 构建 iOS 管道时出现 CodeSign 错误

问题描述 投票:0回答:2

我正在尝试使用 Jenkins 和 Fastlane 构建 iOS 应用程序。 Jenkins master 是一台 Linux 机器,slave 是一台 macOS 机器,两者都运行在 AWS 上。

项目存储库托管在 Gitlab 上。

当管道通过Jenkins运行时,出现以下错误:

以下构建命令失败: 编译Swift正常arm64 CodeSign /Users/ec2-user/Library/Developer/Xcode/DerivedData/AssociatedPress-fccudiwnsqoxlobymusvrmoonnxe/Build/Intermediates.noindex/ArchiveIntermediates/AssociatedPress/IntermediateBuildFilesPath/UninstalledProducts/iphoneos/AssociatedPress\ 通知\ Extension.appex

我的fasy文件的内容是:

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
  • 快车道:2.192.0

我已经尝试过一些解决方案,例如在健身房之前解锁钥匙串、运行 set-key-partition-list 命令,但都没有解决问题。

ios jenkins fastlane codesign fastlane-gym
2个回答
2
投票

如果有人遇到同样的错误,我们发现 iOS 不允许您通过 SSH 访问钥匙串。由于 Jenkins Master 节点使用 SSH 访问 Jenkins Slave 节点,导致访问 keychain 被拒绝,导致 CodeSign 错误。

花了近一周的时间尝试解决这个问题后,我们转向 Gitlab CI/CD 而不是 Jenkins,并实现了我们的目标。


0
投票

我也有类似的情况,我正在使用 ssh 连接到从站。正如here所指出的,这是一个 Apple 安全问题。默认情况下,您无法通过 ssh 访问钥匙串。你必须解锁它。所以在我的 Jenkinsfile 中,在构建 ipa 之前,我运行了这段代码

sh(
      returnStdout: true, 
      script: """
                 cd ~ && security unlock-keychain -p ${env.KEYCHAIN_PASSWORD} || exit 1
              """
).trim()

但不确定是否会有任何安全问题..

© www.soinside.com 2019 - 2024. All rights reserved.