Module: Puppet::Jenkins::Facts

Defined in:
lib/puppet/jenkins/facts.rb

Class Method Summary collapse

Class Method Details

.installNilClass

Method to call the Facter DSL and dynamically add facts at runtime.

This method is necessary to add reasonable RSpec coverage for the custom fact

Returns:

  • (NilClass)


14
15
16
17
18
19
20
21
22
# File 'lib/puppet/jenkins/facts.rb', line 14

def self.install
  Facter.add(:jenkins_plugins) do
    confine kernel: 'Linux'
    setcode do
      Puppet::Jenkins::Facts.plugins_str
    end
  end
  nil
end

.plugins_strString

Return a list of plugins and their versions, e.g.:

pam-auth 1.1, pmd 3.36, rake 1.7.8

Returns:

  • (String)

    Comma-separated version of “<plugin> <version>”, empty string if there are no plugins



29
30
31
32
33
34
35
36
37
# File 'lib/puppet/jenkins/facts.rb', line 29

def self.plugins_str
  plugins = Puppet::Jenkins::Plugins.available
  buffer = []
  plugins.keys.sort.each do |plugin|
    manifest = plugins[plugin]
    buffer << "#{plugin} #{manifest[:plugin_version]}"
  end
  buffer.join(', ')
end