Class: Jenkins2::CLI::ListCredentials

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

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



155
156
157
# File 'lib/jenkins2/cli/credentials.rb', line 155

def self.description
	'List credentials in a specific store.'
end

Instance Method Details

#add_optionsObject



159
160
161
162
163
164
# File 'lib/jenkins2/cli/credentials.rb', line 159

def add_options
	parser.separator 'Mandatory arguments:'
	parser.on '--store STORE', 'Store id. (e.g. "system")' do |s|
		options[:store] = s
	end
end

#mandatory_argumentsObject



166
167
168
# File 'lib/jenkins2/cli/credentials.rb', line 166

def mandatory_arguments
	super + [:store]
end

#runObject



170
171
172
173
174
175
176
177
# File 'lib/jenkins2/cli/credentials.rb', line 170

def run
	jc.credentials.store(options[:store], depth: 2).domains.to_h.collect do |_, v|
		"Domain: #{v.displayName}\n" +
			v.credentials.collect do |crd|
				"#{crd.id} - #{crd.displayName}"
			end.join("\n")
	end.join("\n")
end