module Jujube::Components::Publishers

Helper methods for creating publisher components.

Public Instance Methods

build(options = {}) click to toggle source

Configure a `build` for a {#trigger_parameterized_builds} publisher.

See {docs.openstack.org/infra/jenkins-job-builder/publishers.html#publishers.trigger-parameterized-builds}.

@param options [Hash] The configuration options for the build. @return [Hash] The specification for the build.

# File lib/jujube/components/publishers.rb, line 135
def build(options = {})
  identity = ->(value) { value }
  transforms = {
      predefined_parameters: ->(value) do
        result = value.map { |k,v| "#{k}=#{v}" }.join("\n")
        value.size > 1 ? result + "\n" : result
      end,
      boolean_parameters: ->(value) do
        Hash[value.map { |k,v| [k.to_s, v] }]
      end,
      git_revision: ->(value) do
        value.is_a?(Hash) ? canonicalize_options(value) : value
      end
  }
  transformed_options = options.map do |k, v|
    transform = transforms.fetch(k) { identity }
    [k, transform.call(v)]
  end

  canonicalize_options(Hash[transformed_options])
end
trigger_parameterized_builds() { |builds| ... } click to toggle source

Specify a `trigger-parameterized-builds` publisher for a job.

See {docs.openstack.org/infra/jenkins-job-builder/publishers.html#publishers.trigger-parameterized-builds}.

`trigger-parameterized-builds` can trigger multiple sets of builds, each with their own configuration. Each build specification is added in a nested configuration block using the {#build} method.

@example

job "trigger-parameterized-builds-example" do |j|
  j.publishers << trigger_parameterized_builds do |builds|
    builds << build(project: %w[PROJECT1 PROJECT2], condition: "SUCCESS")
    builds << build(project: "SINGLE_PROJECT", current_parameters: true)
  end
end

@yieldparam builds [Array] An array to which nested build specifications

should be added by the block.

@return [Hash] The specification for the component.

# File lib/jujube/components/publishers.rb, line 99
def trigger_parameterized_builds
  builds = []
  yield(builds) if block_given?
  {"trigger-parameterized-builds" => builds}
end
xunit(options = {}, &block) click to toggle source

Specify an `xunit` publisher for a job.

See {docs.openstack.org/infra/jenkins-job-builder/publishers.html#publishers.xunit}.

`xunit` can publish multiple sets of test results. The specification for each set of test results is added in a nested configuration block using the {#unittest} method.

@example

job "xunit-example" do |j|
  j.publishers << xunit do |types|
    types << unittest(pattern: "PATTERN", deleteoutput: false)
  end
end

@param options [Hash] Top-level options for configuring the component. @yieldparam types [Array] An array to which nested test type specifications should be

added by the block.

@return [Hash] The specification for the component.

# File lib/jujube/components/publishers.rb, line 123
def xunit(options = {}, &block)
  to_config("xunit", nested_options(:types, options, &block))
end