class Autoproj::Jenkins::Credentials
Management of the mapping from a VCS description to the corresponding Jenkins
credential
Constants
- Credential
Attributes
credentials[R]
Public Class Methods
new()
click to toggle source
# File lib/autoproj/jenkins/credentials.rb, line 40 def initialize @credentials = Hash.new end
parse(string)
click to toggle source
Parse a string that represents a single credential and return it
@param [String] string a string of the form “vcs_type:URI”, e.g.
"git:https://github.com"
@return [Credential]
# File lib/autoproj/jenkins/credentials.rb, line 27 def self.parse(string) vcs, *uri = string.split(':') if !vcs || vcs.empty? || uri.empty? raise ArgumentError, "expected VCS:URL but got #{string}" elsif !Autoproj::Jenkins.vcs_supported?(vcs) raise UnhandledVCS, "#{vcs} is not a supported VCS" end uri = URI.parse(uri.join(':')) Credential.new(vcs.to_sym, uri.scheme, uri.host) end
Public Instance Methods
[](vcs)
click to toggle source
# File lib/autoproj/jenkins/credentials.rb, line 48 def [](vcs) credentials[vcs.to_sym] || Array.new end
add(credential)
click to toggle source
# File lib/autoproj/jenkins/credentials.rb, line 52 def add(credential) (credentials[credential.vcs] ||= Array.new) << credential end
empty?()
click to toggle source
# File lib/autoproj/jenkins/credentials.rb, line 44 def empty? credentials.empty? end
for(vcs)
click to toggle source
Return the credential description for the given VCS
@param [Autoproj::VCSDefinition] vcs @return [nil,Credential]
# File lib/autoproj/jenkins/credentials.rb, line 60 def for(vcs) self[vcs.type].find do |c| c.matches?(vcs) end end