Class: JenkinsApi::Client::PluginSettings::WorkspaceCleanup

Inherits:
Base
  • Object
show all
Defined in:
lib/improved_jenkins_client/plugin_settings/workspace_cleanup.rb

Instance Method Summary collapse

Constructor Details

#initialize(params = {}) ⇒ WorkspaceCleanup

Returns a new instance of WorkspaceCleanup.

Parameters:

  • params (Hash) (defaults to: {})

    a customizable set of options

Options Hash (params):

  • :delete_dirs (Boolean) — default: false

    whether to also apply pattern on directories

  • :cleanup_parameters (String)
  • :external_delete (String)


10
11
12
# File 'lib/improved_jenkins_client/plugin_settings/workspace_cleanup.rb', line 10

def initialize(params={})
  @params = params
end

Instance Method Details

#configure(xml_doc) ⇒ Nokogiri::XML::Document

Create or Update a job with params given as a hash instead of the xml This gives some flexibility for creating/updating simple jobs so the user doesn’t have to learn about handling xml.

Parameters:

  • xml_doc (Nokogiri::XML::Document)

    xml document to be updated with the plugin configuration

Returns:

  • (Nokogiri::XML::Document)


21
22
23
24
25
26
27
28
29
30
31
# File 'lib/improved_jenkins_client/plugin_settings/workspace_cleanup.rb', line 21

def configure(xml_doc)
  xml_doc.tap do |doc|
    Nokogiri::XML::Builder.with(doc.at('buildWrappers')) do |build_wrappers|
      build_wrappers.send('hudson.plugins.ws__cleanup.PreBuildCleanup') do |x|
        x.deleteDirs @params.fetch(:delete_dirs) { false }
        x.cleanupParameter @params.fetch(:cleanup_parameter) { '' }
        x.externalDelete @params.fetch(:external_delete) { '' }
      end
    end
  end
end