Class: Lita::Handlers::JenkinsClient::BaseAction

Inherits:
Action show all
Defined in:
lib/lita/handlers/jenkins_client/base_action.rb

Constant Summary

Constants inherited from Lita::Handlers::JenkinsClient

CONFIGS

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.commandsObject



10
11
12
13
14
15
16
# File 'lib/lita/handlers/jenkins_client/base_action.rb', line 10

def self.commands
  super.merge ({
    version: Command.new(name: 'version', matcher: 'version', help: 'get jenkins version.'),
    cli: Command.new(name: 'cli', matcher: 'cli', help: 'executes the jenkins cli.', usage: 'cli [command]'),
    running?: Command.new(name: 'running?', matcher: 'running', help: 'Show if jenkins is running.'),
  })
end

Instance Method Details

#cli(res) ⇒ Object



24
25
26
27
28
29
30
31
32
# File 'lib/lita/handlers/jenkins_client/base_action.rb', line 24

def cli(res)
  if res.args.length < 2
    res.reply 'Please provide at least one command'
    return 
  end
  res.reply api_exec(usage(:cli)) { 
    client.exec_cli(res.args.slice(1...res.args.length).join(' '))
  }
end

#running?(res) ⇒ Boolean

Returns:

  • (Boolean)


34
35
36
37
38
39
# File 'lib/lita/handlers/jenkins_client/base_action.rb', line 34

def running?(res)
  res.reply api_exec { 
    client.get_root.inspect
    "Running"
  }
end

#version(res) ⇒ Object



18
19
20
21
22
# File 'lib/lita/handlers/jenkins_client/base_action.rb', line 18

def version(res)
  res.reply api_exec { 
    client.get_jenkins_version
  }
end