Sha256: 2ad792f0855d2ae1c4ee118fa0da473670bf255f85f2e8cabdf00d0f055c54a3

Contents?: true

Size: 1.57 KB

Versions: 74

Compression:

Stored size: 1.57 KB

Contents

module Fastlane
  module Actions
    class EnsureEnvVarsAction < Action
      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

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

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

      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

      def self.authors
        ['revolter']
      end

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

      def self.category
        :misc
      end

      def self.is_supported?(platform)
        true
      end
    end
  end
end

Version data entries

74 entries across 74 versions & 4 rubygems

Version Path
fastlane-2.226.0 fastlane/lib/fastlane/actions/ensure_env_vars.rb
fastlane-2.225.0 fastlane/lib/fastlane/actions/ensure_env_vars.rb
fastlane-2.224.0 fastlane/lib/fastlane/actions/ensure_env_vars.rb
fastlane-2.223.1 fastlane/lib/fastlane/actions/ensure_env_vars.rb
fastlane-2.223.0 fastlane/lib/fastlane/actions/ensure_env_vars.rb
fastlane-2.222.0 fastlane/lib/fastlane/actions/ensure_env_vars.rb
fastlane-2.221.1 fastlane/lib/fastlane/actions/ensure_env_vars.rb
fastlane-2.221.0 fastlane/lib/fastlane/actions/ensure_env_vars.rb
fastlane-2.220.0 fastlane/lib/fastlane/actions/ensure_env_vars.rb
fastlane-2.219.0 fastlane/lib/fastlane/actions/ensure_env_vars.rb
fastlane-2.218.0 fastlane/lib/fastlane/actions/ensure_env_vars.rb
fastlane-security-patched-2.216.0 fastlane/lib/fastlane/actions/ensure_env_vars.rb
fastlane-2.217.0 fastlane/lib/fastlane/actions/ensure_env_vars.rb
fastlane-2.216.0 fastlane/lib/fastlane/actions/ensure_env_vars.rb
fastlane-2.215.1 fastlane/lib/fastlane/actions/ensure_env_vars.rb
fastlane-2.215.0 fastlane/lib/fastlane/actions/ensure_env_vars.rb
fastlane-mercafacil-2.214.0 fastlane/lib/fastlane/actions/ensure_env_vars.rb
fastlane-2.214.0 fastlane/lib/fastlane/actions/ensure_env_vars.rb
fastlane-2.213.0 fastlane/lib/fastlane/actions/ensure_env_vars.rb
fastlane-2.212.2 fastlane/lib/fastlane/actions/ensure_env_vars.rb