Class: Jenkins2::CLI::AssignRole

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

Overview

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



78
79
80
# File 'lib/jenkins2/cli/role_strategy.rb', line 78

def self.description
	'Assign role to user in role-strategy plugin.'
end

Instance Method Details

#add_optionsObject



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

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



95
96
97
# File 'lib/jenkins2/cli/role_strategy.rb', line 95

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

#runObject



99
100
101
# File 'lib/jenkins2/cli/role_strategy.rb', line 99

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