Bitrise repeatedly asking 2Factor authentication on fastlane actions

fastlane
ios
#1

We successfully connected Apple Developer Connection with the trusted phone number verification. As this
2FA fails while connecting to Apple Developer portal suggested .

Now when we creating a build on bitrise , it sucessfully exported session as following logs

e[34;1mConnected Apple Developer Portal Account found, exposing FASTLANE_SESSION env vare[0m
e[32;1mSession exportede[0m]

========================
But still bitrise is asking

Two-factor Authentication (6 digits code) is enabled for account '[REDACTED]'
More information about Two-factor Authentication: https://support.apple.com/en-us/HT204915

If you're running this in a non-interactive session (e.g. server or CI)
check out https://github.com/fastlane/fastlane/tree/master/spaceship#2-step-verification

(Input `sms` to escape this prompt and select a trusted phone number to send the code as a text message)

(You can also set the environment variable `SPACESHIP_2FA_SMS_DEFAULT_PHONE_NUMBER` to automate this)
(Read more at: https://github.com/fastlane/fastlane/blob/master/spaceship/docs/Authentication.md#auto-select-sms-via-spaceship-2fa-sms-default-phone-number)

==========================
Current Fastlane version: 2.140.0.

Please help and guide us since our CI is blocked with this

======================
Optional Logs

bundler: failed to load command: fastlane (/Users/vagrant/.rbenv/versions/2.6.5/bin/fastlane)
NoMethodError: e[31m[!] undefined method `strip' for nil:NilClass
Did you mean?  Stringe[0m
  /Users/vagrant/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/highline-1.7.10/lib/highline/question.rb:413:in `remove_whitespace'
  /Users/vagrant/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/highline-1.7.10/lib/highline.rb:873:in `get_line'
  /Users/vagrant/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/highline-1.7.10/lib/highline.rb:891:in `get_response'
  /Users/vagrant/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/highline-1.7.10/lib/highline.rb:264:in `ask'
  /Users/vagrant/.rbenv/versions/2.6.5/lib/ruby/2.6.0/forwardable.rb:230:in `ask'
  /Users/vagrant/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/fastlane-2.140.0/spaceship/lib/spaceship/two_step_or_factor_client.rb:196:in `ask_for_2fa_code'
  /Users/vagrant/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/fastlane-2.140.0/spaceship/lib/spaceship/two_step_or_factor_client.rb:145:in `handle_two_factor'
  /Users/vagrant/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/fastlane-2.140.0/spaceship/lib/spaceship/two_step_or_factor_client.rb:20:in `handle_two_step_or_factor'
  /Users/vagrant/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/fastlane-2.140.0/spaceship/lib/spaceship/client.rb:494:in `send_shared_login_request'
  /Users/vagrant/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/fastlane-2.140.0/spaceship/lib/spaceship/tunes/tunes_client.rb:127:in `send_login_request'
  /Users/vagrant/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/fastlane-2.140.0/spaceship/lib/spaceship/client.rb:775:in `do_login'
  /Users/vagrant/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/fastlane-2.140.0/spaceship/lib/spaceship/client.rb:384:in `login'
  /Users/vagrant/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/fastlane-2.140.0/spaceship/lib/spaceship/client.rb:346:in `login'
  /Users/vagrant/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/fastlane-2.140.0/spaceship/lib/spaceship/tunes/spaceship.rb:24:in `login'
  Versionfile:13:in `set_version_number'
  Versionfile:5:in `set_version'
  Fastfile:50:in `block (2 levels) in parsing_binding'
  /Users/vagrant/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/fastlane-2.140.0/fastlane/lib/fastlane/lane.rb:33:in `call'
  /Users/vagrant/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/fastlane-2.140.0/fastlane/lib/fastlane/runner.rb:204:in `try_switch_to_lane'
  /Users/vagrant/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/fastlane-2.140.0/fastlane/lib/fastlane/runner.rb:146:in `trigger_action_by_name'
  /Users/vagrant/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/fastlane-2.140.0/fastlane/lib/fastlane/fast_file.rb:159:in `method_missing'
  Fastfile:38:in `block (2 levels) in parsing_binding'
  /Users/vagrant/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/fastlane-2.140.0/fastlane/lib/fastlane/lane.rb:33:in `call'
  /Users/vagrant/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/fastlane-2.140.0/fastlane/lib/fastlane/runner.rb:49:in `block in execute'
  /Users/vagrant/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/fastlane-2.140.0/fastlane/lib/fastlane/runner.rb:45:in `chdir'
  /Users/vagrant/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/fastlane-2.140.0/fastlane/lib/fastlane/runner.rb:45:in `execute'
  /Users/vagrant/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/fastlane-2.140.0/fastlane/lib/fastlane/lane_manager.rb:56:in `cruise_lane'
  /Users/vagrant/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/fastlane-2.140.0/fastlane/lib/fastlane/command_line_handler.rb:36:in `handle'
  /Users/vagrant/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/fastlane-2.140.0/fastlane/lib/fastlane/commands_generator.rb:108:in `block (2 levels) in run'
  /Users/vagrant/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/commander-fastlane-4.4.6/lib/commander/command.rb:178:in `call'
  /Users/vagrant/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/commander-fastlane-4.4.6/lib/commander/command.rb:153:in `run'
  /Users/vagrant/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/commander-fastlane-4.4.6/lib/commander/runner.rb:476:in `run_active_command'
  /Users/vagrant/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/fastlane-2.140.0/fastlane_core/lib/fastlane_core/ui/fastlane_runner.rb:76:in `run!'
  /Users/vagrant/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/commander-fastlane-4.4.6/lib/commander/delegates.rb:15:in `run!'
  /Users/vagrant/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/fastlane-2.140.0/fastlane/lib/fastlane/commands_generator.rb:349:in `run'
  /Users/vagrant/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/fastlane-2.140.0/fastlane/lib/fastlane/commands_generator.rb:41:in `start'
  /Users/vagrant/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/fastlane-2.140.0/fastlane/lib/fastlane/cli_tools_distributor.rb:119:in `take_off'
  /Users/vagrant/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/fastlane-2.140.0/bin/fastlane:23:in `<top (required)>'
  /Users/vagrant/.rbenv/versions/2.6.5/bin/fastlane:23:in `load'
  /Users/vagrant/.rbenv/versions/2.6.5/bin/fastlane:23:in `<top (required)>'

e[31;1mFastlane command: (bundle "_2.1.4_" "exec" "fastlane" "ios" "beta") failede[0m
e[31;1mIf you want to send an issue report to fastlane (https://github.com/fastlane/fastlane/issues/new), you can find the output of fastlane env in the following log file:e[0m

e[34;1m/Users/vagrant/deploy/fastlane_env.loge[0m

e[35;1m$ bundle "_2.1.4_" "exec" "fastlane" "env"e[0m
e[31;1mCommand failed, error: exit status 1e[0m

===============================
If I run command on my local machine it doesn’t ask for 2 factor authentication since it is authenticated device . Question is why I can’t make bitrise machine as a trusted it also verified by two factor authentication.

0 Likes

#2

test for the web view

0 Likes

#3

Hey @aliakhtar49!

Unfortunately, this is happening due to an ongoing bug we have. The Fastlane step does not correctly get the FASTLANE_SESSION variable. The workaround for now, is to use a Script step to launch your fastlane and define the variable manually on the website.

We’ll make sure to update this thread too once the fix is released!

0 Likes

#4

Sure thanks for the update ,
also we faced issue with the script workaround may be regional issue problem for FASTLANE_SESSION variable . It also logged “exported successfully” but asking again 2factor things.

I also try to create a FASTLANE_SESSION on bitrise machine by using remote debugging and it didn’t work as well

Question: If we configured Auto Provision thing , will it be used by fastlane to talk to itunes connect for other things

0 Likes

#5

Any updates on this issue?

0 Likes

#6

Hi everyone experiencing this issue!

This bug is unfortunately still present, but the workaround should be valid:

You can define the variable on the website in the Env Vars tab, or as a secret, and launch your fastlane from a Script step instead of the Fastlane step.

Question: If we configured Auto Provision thing , will it be used by fastlane to talk to itunes connect for other things

Not entirely. It’s different from step-to-step - for example some Deploy steps allow you to provide username and password (and app-specific password directly.) But in general step rely on the connected Apple Developer Portal accounts to pass down the info and create the necessary variables. This is what’s not working for the Fastlane step at the moment.

0 Likes

#7

@bitce The problem with this workaround is that the FASTLANE_SESSION expires after 8 hours and it needs to be updated constantly :confused: can we do something about this?

0 Likes

#8

@Artland, I do believe this is a limitation on Fastlane due to Apple’s side. At the moment there is no further workaround we can provide. (Let it be known that our own tools work well, it’s our Fastlane integration that is affected only.)

I’ll make sure to bump the priority of the task as much as we can!

0 Likes