Custom Variable in Fastlane Script

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


ANSWERS:


You set a variable using the = operator, just as you have on line 4. A local variable exists only within the scope where it's created. Assuming the block passed to lane is called before block passed to after_all, then changing the first line to message = nil (so that the variable exists outside the first block's scope) ought to work:

message = nil

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

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

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


 MORE:


 ? How to set a default value for a splat argument in Ruby
 ? Rails Devise No Method Error for Registrations for Stripe Checkout
 ? Take a picture from gallery dosen't work
 ? How to implement a Stripe Checkout custom button
 ? Using Node.JS to Issue a Command from a Text File
 ? C: Accessing the second argv via a pointer
 ? is it possible to run ruby commandline tool irb in android device?
 ? OCR validations with Rails building a business card scanner
 ? how to use render json: with active-model-serializers gem?
 ? Why would Rails ignore a migration files when running `rake db:migrate`?