Class: Jenkins2::CLI::UnassignRole

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

Overview

Provides unassign-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



106
107
108
# File 'lib/jenkins2/cli/role_strategy.rb', line 106

def self.description
	'Unassign role from user in role-strategy plugin.'
end

Instance Method Details

#add_optionsObject



110
111
112
113
114
115
116
117
118
119
120
121
# File 'lib/jenkins2/cli/role_strategy.rb', line 110

def add_options
	parser.separator 'Mandatory arguments:'
	parser.on '--role ROLE', 'Role name.' do |r|
		options[:role] = r
	end
	parser.on '--type TYPE', 'Role type. One of: globalRoles, projectRoles, slaveRoles.' do |t|
		options[:type] = t
	end
	parser.on '--rsuser USER', 'Username.' do |u|
		options[:rsuser] = u
	end
end

#mandatory_argumentsObject



123
124
125
# File 'lib/jenkins2/cli/role_strategy.rb', line 123

def mandatory_arguments
	super + %i[role type rsuser]
end

#runObject



127
128
129
# File 'lib/jenkins2/cli/role_strategy.rb', line 127

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