Class: Jenkins2::CLI::DeleteRoles

Inherits:
Jenkins2::CLI show all
Defined in:
lib/jenkins2/cli/role_strategy.rb

Overview

Provides delete-role command in CLI. Requires role-strategy plugin enabled.

Instance Attribute Summary

Attributes inherited from Jenkins2::CLI

#errors, #options

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Jenkins2::CLI

#call, class_to_command, #initialize, #parse, subcommands

Constructor Details

This class inherits a constructor from Jenkins2::CLI

Class Method Details

.descriptionObject



53
54
55
# File 'lib/jenkins2/cli/role_strategy.rb', line 53

def self.description
	'Delete role(s) in role-strategy plugin.'
end

Instance Method Details

#add_optionsObject



57
58
59
60
61
62
63
64
65
# File 'lib/jenkins2/cli/role_strategy.rb', line 57

def add_options
	parser.separator 'Mandatory arguments:'
	parser.on '--role X,Y,..', Array, 'Role names.' do |r|
		options[:role] = r
	end
	parser.on '--type TYPE', 'Role type. One of: globalRoles, projectRoles, slaveRoles.' do |t|
		options[:type] = t
	end
end

#mandatory_argumentsObject



67
68
69
# File 'lib/jenkins2/cli/role_strategy.rb', line 67

def mandatory_arguments
	super + %i[role type]
end

#runObject



71
72
73
# File 'lib/jenkins2/cli/role_strategy.rb', line 71

def run
	jc.roles.delete(role: options[:role], type: options[:type])
end