Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to set environment variables in fastlane?

I had read the documents but I am still confused where to set the environment variables in the fastfile or the bash_profile. Can you please help me out with that?

What I want to achieve is to set the apple developer credentials in fastfile and should not ask again if any user takes pull of my code and try to build it.

I am writing this in fastlane file. Let me know if I am wrong.

default_platform(:ios)

platform :ios do

ENV["FASTLANE_DONT_STORE_PASSWORD"] = "1"
ENV["FASTLANE_USER"] = ""
ENV["FASTLANE_PASSWORD"] = ""

desc "GENERATE SCREENSHOT"
lane :Snaps do
capture_screenshots
end

end
like image 243
Parth Adroja Avatar asked Feb 07 '18 09:02

Parth Adroja


1 Answers

You can add environment variables in before_all. Try this.

platform :ios do
  before_all do
    ENV["FASTLANE_DONT_STORE_PASSWORD"] = "1"
    ENV["FASTLANE_USER"] = ""
    ENV["FASTLANE_PASSWORD"] = ""
  end

  desc "GENERATE SCREENSHOT"
  lane :Snaps do
    capture_screenshots
  end
end

To not store your keys in git, you can pass all parameters of all actions using environment variables.

You can edit your ~/.bash_profile to include something like

export FASTLANE_DONT_STORE_PASSWORD ="1"
export FASTLANE_USER =""
export FASTLANE_PASSWORD =""
like image 126
Bilal Avatar answered Sep 21 '22 15:09

Bilal