class Jenkins2API::ThorCommand
Wrapper class for commands. Checks if credentials are passed or not and creates a new Jenkins2API::Client
instance for commands.
Private Instance Methods
check_option(name, env_name)
click to toggle source
Check option or environment variable content
# File lib/thor_command.rb, line 28 def check_option(name, env_name) options[name] ||= ENV.fetch(env_name, '') return if options.key?(name.to_s) && options[name] != '' raise Thor::Error, "#{name} is not defined. " \ "You can specify with --#{name} option " \ "or '#{env_name}' environment variable." end
client()
click to toggle source
Get or create a new client
# File lib/thor_command.rb, line 15 def client check_option(:server, 'JENKINS_SERVER') check_option(:username, 'JENKINS_USERNAME') check_option(:password, 'JENKINS_PASSWORD') @client ||= Jenkins2API::Client.new( server: options[:server], username: options[:username], password: options[:password] ) end