Class: Jenkins2::CLI::CreateRole
Overview
Provides create-role command in CLI. Requires role-strategy plugin enabled.
Instance Attribute Summary
#errors, #options
Class Method Summary
collapse
Instance Method Summary
collapse
#call, class_to_command, #initialize, #parse, subcommands
Constructor Details
This class inherits a constructor from Jenkins2::CLI
Class Method Details
.description ⇒ Object
20
21
22
|
# File 'lib/jenkins2/cli/role_strategy.rb', line 20
def self.description
'Create a role in role-strategy plugin.'
end
|
Instance Method Details
#add_options ⇒ Object
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
|
# File 'lib/jenkins2/cli/role_strategy.rb', line 24
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.separator 'Optional arguments:'
parser.on '--permissions X,Y,..', Array, 'Comma-separated list of permissions.' do |p|
options[:permissions] = p
end
parser.on '--pattern PATTERN', 'Slave or project pattern. Ignored for global roles.' do |p|
options[:pattern] = p
end
end
|
#mandatory_arguments ⇒ Object
41
42
43
|
# File 'lib/jenkins2/cli/role_strategy.rb', line 41
def mandatory_arguments
super + %i[role type]
end
|
#run ⇒ Object
45
46
47
48
|
# File 'lib/jenkins2/cli/role_strategy.rb', line 45
def run
jc.roles.create(role: options[:role], type: options[:type],
permissions: options[:permissions], pattern: options[:pattern])
end
|