Class: JenkinsApi::CLI::Node

Inherits:
Thor
  • Object
show all
Includes:
Terminal, Thor::Actions
Defined in:
lib/jenkins_api_client/cli/node.rb

Overview

This class provides various command line operations for the Node class.

Instance Method Summary (collapse)

Instance Method Details

- (Object) list

CLI command that lists all nodes/slaves available in Jenkins or the ones matching the filter provided



39
40
41
42
43
44
45
46
# File 'lib/jenkins_api_client/cli/node.rb', line 39

def list
  @client = Helper.setup(parent_options)
  if options[:filter]
    puts @client.node.list(options[:filter])
  else
    puts @client.node.list
  end
end

CLI command that prints the general attribtues of nodes



50
51
52
53
54
55
56
57
58
59
# File 'lib/jenkins_api_client/cli/node.rb', line 50

def print_general_attributes
  @client = Helper.setup(parent_options)
  general_attributes = Client::Node::GENERAL_ATTRIBUTES
  rows = []
  general_attributes.each do |attr|
    rows << [attr, @client.node.method("get_#{attr}").call]
  end
  table = Table.new :headings => ['Attribute', 'Value'], :rows => rows
  puts table
end

CLI command to print the attributes specific to a node

Parameters:

  • node (String)

    Name of the node



66
67
68
69
70
71
72
73
74
75
76
# File 'lib/jenkins_api_client/cli/node.rb', line 66

def print_node_attributes(node)
  @client = Helper.setup(parent_options)
  node_attributes = Client::Node::NODE_ATTRIBUTES
  rows = []
  node_attributes.each do |attr|
    rows << [attr, @client.node.method("get_node_#{attr}").call(node)]
  end
  table = Table.new :headings => ['Attribute', 'Value'], :rows => rows
  puts "Node: #{node}"
  puts table
end

CLI command to print the properties of a specific node

Parameters:

  • node (String)

    Name of the node



83
84
85
86
87
88
89
90
91
92
93
# File 'lib/jenkins_api_client/cli/node.rb', line 83

def print_node_properties(node)
  @client = Helper.setup(parent_options)
  node_properties = Client::Node::NODE_PROPERTIES
  rows = []
  node_properties.each do |property|
    rows << [property, @client.node.method("is_#{property}?").call(node)]
  end
  table = Table.new :headings => ['Property', 'Value'], :rows => rows
  puts "Node: #{node}"
  puts table
end