Class: Fastlane::Actions::EnsureEnvVarsAction

Inherits:
Fastlane::Action show all
Defined in:
fastlane/lib/fastlane/actions/ensure_env_vars.rb

Constant Summary

Constants inherited from Fastlane::Action

Fastlane::Action::AVAILABLE_CATEGORIES, Fastlane::Action::RETURN_TYPES

Class Method Summary collapse

Methods inherited from Fastlane::Action

action_name, author, deprecated_notes, lane_context, method_missing, other_action, output, return_type, return_value, sample_return_value, shell_out_should_use_bundle_exec?, step_text

Class Method Details

.authorsObject



37
38
39
# File 'fastlane/lib/fastlane/actions/ensure_env_vars.rb', line 37

def self.authors
  ['revolter']
end

.available_optionsObject



26
27
28
29
30
31
32
33
34
35
# File 'fastlane/lib/fastlane/actions/ensure_env_vars.rb', line 26

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

.categoryObject



49
50
51
# File 'fastlane/lib/fastlane/actions/ensure_env_vars.rb', line 49

def self.category
  :misc
end

.descriptionObject



18
19
20
# File 'fastlane/lib/fastlane/actions/ensure_env_vars.rb', line 18

def self.description
  'Raises an exception if the specified env vars are not set'
end

.detailsObject



22
23
24
# File 'fastlane/lib/fastlane/actions/ensure_env_vars.rb', line 22

def self.details
  'This action will check if some environment variables are set.'
end

.example_codeObject



41
42
43
44
45
46
47
# File 'fastlane/lib/fastlane/actions/ensure_env_vars.rb', line 41

def self.example_code
  [
    'ensure_env_vars(
      env_vars: [\'GITHUB_USER_NAME\', \'GITHUB_API_TOKEN\']
    )'
  ]
end

.is_supported?(platform) ⇒ Boolean

Returns:



53
54
55
# File 'fastlane/lib/fastlane/actions/ensure_env_vars.rb', line 53

def self.is_supported?(platform)
  true
end

.run(params) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
15
16
# File 'fastlane/lib/fastlane/actions/ensure_env_vars.rb', line 4

def self.run(params)
  variables = params[:env_vars]

  variables.each do |variable|
    next unless ENV[variable].to_s.strip.empty?

    UI.user_error!("Missing environment variable '#{variable}'")
  end

  is_one = variables.length == 1

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