class Fastlane::Actions::EnsureEnvVarsAction

Public Class Methods

authors() click to toggle source
# File fastlane/lib/fastlane/actions/ensure_env_vars.rb, line 33
def self.authors
  ['revolter']
end
available_options() click to toggle source
# File fastlane/lib/fastlane/actions/ensure_env_vars.rb, line 22
def self.available_options
  [
    FastlaneCore::ConfigItem.new(key: :env_vars,
                                 description: 'The environment variables names that should be checked',
                                 type: Array,
                                 verify_block: proc do |value|
                                   UI.user_error!('Specify at least one environment variable name') if value.empty?
                                 end)
  ]
end
category() click to toggle source
# File fastlane/lib/fastlane/actions/ensure_env_vars.rb, line 45
def self.category
  :misc
end
description() click to toggle source
# File fastlane/lib/fastlane/actions/ensure_env_vars.rb, line 14
def self.description
  'Raises an exception if the specified env vars are not set'
end
details() click to toggle source
# File fastlane/lib/fastlane/actions/ensure_env_vars.rb, line 18
def self.details
  'This action will check if some environment variables are set.'
end
example_code() click to toggle source
# File fastlane/lib/fastlane/actions/ensure_env_vars.rb, line 37
def self.example_code
  [
    'ensure_env_vars(
      env_vars: [\'GITHUB_USER_NAME\', \'GITHUB_API_TOKEN\']
    )'
  ]
end
is_supported?(platform) click to toggle source
# File fastlane/lib/fastlane/actions/ensure_env_vars.rb, line 49
def self.is_supported?(platform)
  true
end
run(params) click to toggle source
# File fastlane/lib/fastlane/actions/ensure_env_vars.rb, line 4
def self.run(params)
  variables = params[:env_vars]
  missing_variables = variables.select { |variable| ENV[variable].to_s.strip.empty? }

  UI.user_error!("Missing environment variable(s) '#{missing_variables.join('\', \'')}'") unless missing_variables.empty?

  is_one = variables.length == 1
  UI.success("Environment variable#{is_one ? '' : 's'} '#{variables.join('\', \'')}' #{is_one ? 'is' : 'are'} set!")
end