Class: Jenkins2API::Command::Node

Inherits:
ThorCommand show all
Defined in:
lib/commands/node.rb

Overview

Contains all the commands under node namespace

Constant Summary collapse

MASTER_CLASS =

Jenkins java class of the master instance

'hudson.model.Hudson$MasterComputer'.freeze

Instance Method Summary collapse

Instance Method Details

#allObject

List all available nodes



13
14
15
16
17
18
19
20
# File 'lib/commands/node.rb', line 13

def all
  nodes = client.node.all
  nodes['computer'].each do |computer|
    type = 'slave'
    type = 'master' if computer['_class'] == MASTER_CLASS
    printf("[%6s] %s\n", type, computer['displayName'])
  end
end

#slavesObject

List all avilable slaves



24
25
26
27
28
29
30
# File 'lib/commands/node.rb', line 24

def slaves
  nodes = client.node.all
  nodes['computer'].each do |computer|
    next if computer['_class'] == MASTER_CLASS
    puts computer['displayName']
  end
end