Class: JenkinsApi::Client::PluginSettings::Hipchat

Inherits:
Base
  • Object
show all
Defined in:
lib/jenkins_api_client/plugin_settings/hipchat.rb

Instance Method Summary collapse

Constructor Details

#initialize(params = {}) ⇒ Hipchat

Returns a new instance of Hipchat.

Parameters:

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

    a customizable set of options

Options Hash (params):

  • :room (String)

    id of the room

  • :start_notification (Boolean) — default: false

    whether to notify room when build starts

  • :notify_success (Boolean) — default: false

    whether to notify room when build succeeds

  • :notify_aborted (Boolean) — default: false

    whether to notify room when build aborts

  • :notify_not_built (Boolean) — default: false

    whether to notify room when job could not be build

  • :notify_unstable (String)

    whether to notify room when job becomes unstable

  • :notify_failure (String)

    whether to notify room when job fails

  • :notify_back_to_normal (String)

    whether to notify room when job becomes stable



23
24
25
# File 'lib/jenkins_api_client/plugin_settings/hipchat.rb', line 23

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)


34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# File 'lib/jenkins_api_client/plugin_settings/hipchat.rb', line 34

def configure(xml_doc)
  xml_doc.tap do |doc|
    Nokogiri::XML::Builder.with(doc.at('properties')) do |properties|
      properties.send('jenkins.plugins.hipchat.HipChatNotifier_-HipChatJobProperty') do |x|
        x.room @params.fetch(:room) { '' }
        x.startNotification @params.fetch(:start_notification) { false }
        x.notifySuccess @params.fetch(:notify_success) { false }
        x.notifyAborted @params.fetch(:notify_aborted) { false }
        x.notifyNotBuilt @params.fetch(:notify_not_built) { false }
        x.notifyUnstable @params.fetch(:notify_unstable) { false }
        x.notifyFailure @params.fetch(:notify_failure) { false }
        x.notifyBackToNormal @params.fetch(:notify_back_to_normal) { false }
      end
    end
  end
end