4

My shell script would trigger a fastlane action (ruby) and I need return some value back to the shell script

One option being suggested everywhere is to set it as a env variable. But unable to print the value in shell script.

Fastlane action

platform :ios do
  desc "Description of what the lane does"
  lane :getData do
        ENV['FL_VALUE'] = "Test"
  end
end

Sample shell script

!/bin/sh
...
bundle exec fastlane getData
...
echo $FL_VALUE

other suggestions were to write the data into some file and read it from the shell script. But would prefer to use the env variable.

nakeer
  • 641
  • 1
  • 9
  • 17
  • 1
    You can’t export an ENV variable to the parent shell from ruby but you can write a bash file that does it see https://stackoverflow.com/questions/2660571/exporting-an-environment-variable-in-ruby – Guillermo Siliceo Trueba Jul 10 '19 at 02:00
  • 1
    Please open an issue at the fastlane repository with a feature request - being able to return data from a lane seems like a reasonable and very useful thing. – janpio Jul 10 '19 at 08:53
  • saw couple of postings requesting for that on their github repo, but no solution yet from then. But yes, will give a shot – nakeer Jul 19 '19 at 05:52

1 Answers1

1

The project I am working on calls fastlane scripts from Groovy scripts. We have the lanes take an output_file option and write their results there. The Groovy scripts then read the results from the file. Cumbersome, but effective.

BTW: we also have an error_file option so errors can be written out similarly...

Marc Attinasi
  • 5,644
  • 1
  • 16
  • 7