3

I am trying to build iOS app using Jenkins and Fastlane. Jenkins master is a Linux machine and slave is a macOS machine, both running on AWS.

Project repository is hosted on Gitlab.

When the pipeline is run through Jenkins, it gives the following error:

The following build commands failed: CompileSwift normal arm64 CodeSign /Users/ec2-user/Library/Developer/Xcode/DerivedData/AssociatedPress-fccudiwnsqoxlobymusvrmoonnxe/Build/Intermediates.noindex/ArchiveIntermediates/AssociatedPress/IntermediateBuildFilesPath/UninstalledProducts/iphoneos/AssociatedPress\ Notification\ Extension.appex

The contents of my fasyfile are:

node('macos') {
    {
        stage('Checkout') {
            checkout scm
        }

        stage('Resolve packages') {
            sh 'bash resolvePackages'
        }

        stage('Build Store') {
            sh 'fastlane store'
        }
    }
} 

Fastfile is as follows:-

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

Build only fails on CodeSign when it is run through Jenkins. When fastlane commands are run locally on macOS slave node, build succeeds.

Versions:-

  • macOS: 11.5.1
  • xocde version: 12.5.1
  • fastlane: 2.192.0

I have already tried some of the solutions such as unlocking the keychain before gym, running set-key-partition-list command, none of them solved the issue.

  • "Build only fails on CodeSign when it is run through Jenkins." This suggests that the certificates/keys on your local machine are different than the build machine. – pietrorea Sep 04 '21 at 17:39
  • @pietrorea apologies for late reply. Certificates/keys were correct on the build machine because when we used fastlane commands by logging into the build machine, the build succeeds, it only fails through Jenkins. – Uqqasha Ijaz Apr 11 '22 at 16:58
  • I've been in this error for months, how did you manage to solve it? @pietrorea – Anderson Bressane Apr 11 '23 at 09:22

1 Answers1

1

Anyone stumbling upon the same error, we found out that iOS does not allow you to access the keychain through SSH. Since Jenkins Master node uses SSH to access Jenkins Slave node, access to keychain is denied resulting in CodeSign error.

After spending almost a week trying to fix this, we shifted to Gitlab CI/CD instead of Jenkins and achieved our goal.