Custom Variable in Fastlane Script

EHorodyski picture EHorodyski · Feb 9, 2017 · Viewed 9.4k times · Source

Sorry for such a newbie question, but I'm very confused on how to write a Fastlane script outside of using the supplied methods.

What I'm looking to do is create a variable called message, that can be passed to the after_all function, so when I post to Slack, each lane can have it's own custom message:

put message # is this how to set a variable?
lane :alpha do
    # This is what I'd like to do
    message = "[Google Play] Alpha Channel Deployed"
end

after_all |lane, options| do
    slack(message: message)
end

Can anyone point me in the right direction? I'm so utterly lost on how to create and pass variables that don't come from the command line in a Fastfile script

Answer

KrauseFx picture KrauseFx · Feb 9, 2017

Alternatively you can also do the following:

lane :alpha do
  @message = "[Google Play] Alpha Channel Deployed"
end

after_all |lane, options| do
  slack(message: @message)
end