Jenkins “Login to App Store Connect (xxx)
Available session is not valid any more. Continuing with normal login. Two-factor Authentication (6 digits code) is enabled for account” error handling

(Jenkins, Two-factor Authentication, App Store Connect)

jenkins在自動部署iOS APP至App Connec時
部版失敗,且錯誤原因如下圖之訊息

Login to App Store Connect (xxx)
Available session is not valid any more. Continuing with normal login.
Session loaded from environment variable is not valid. Continuing with normal login.
Two-factor Authentication (6 digits code) is enabled for account 'xxx'

並且在裝置上跳出尋求雙重認證的圖

表示FASTLANE_SESSION過期了
可以參考本文更新FASTLANE_SESSION

什麼是FASTLANE_SESSION?

原因是登入App store 需要雙重認證
透過Xcode包版時,自動有憑證不需要雙重認證
但透過Jenkins包版時,透過command line去使用Xcode打包的方式上傳App Store,因此需要提供雙重認證

因此透過Fastlane設定FASTLANE_SESSION機制,且FASTLANE_SESSION 有效日期為一個月,讓更新時無需做雙重認證

更換FASTLANE_SESSION

從終端機,移至專案中fastlane的資料夾

在fastlane資料夾中下

bundle exec fastlane spaceauth -u <your apple ID email>

因為第一次執行,尚未安裝 fastlane,須先安裝

bundle install fastlane

安裝完後,在執行一次command

bundle exec fastlane spaceauth -u <your apple ID email>

並會要求輸入 apple ID email的密碼

輸6位數雙重認證
認證碼會傳送到機器上

出現下面文字,表示成功連到App Store Connect

詢問是否 長長青色的文字 複製cookie到剪貼簿?按 y

出現下面文字,表示成功複製cookie到剪貼簿(方便下步驟直接貼上數值)

開啟專案底下的Fastfile檔案

取代FASTLANE_SESSION的參數

ENV[“FASTLANE_SESSION”] = ''

存檔案後,更新至git
再次自動佈版即可排除此異常

--

--