Sha256: 923f6464511c8fe114eaaed7bef85dae0bd4fd9219123c4cc1411271fd79e417

Contents?: true

Size: 815 Bytes

Versions: 4

Compression:

Stored size: 815 Bytes

Contents

require 'gocd'
require 'yaml'

module GOCD_PRE_PUSH
  class BuildInformer
    attr_reader :pipelines

    def initialize(pipelines, gocd_server)
      GOCD.server = GOCD::Server.new gocd_server.url
      GOCD.credentials = GOCD::Credentials.new gocd_server.username, gocd_server.password

      pipelines = YAML::load_file pipelines
      pipelines.map! { |pipeline| pipeline_stage_name pipeline }.flatten!
      @pipelines = GOCD::PipelineGroup.new(pipelines, cache: true)
    end

    def information_available?
      @pipelines.information_available?
    end

    def red_pipelines
      @pipelines.red_pipelines
    end

    def any_red?
      @pipelines.any_red?
    end

    private
    def pipeline_stage_name(pipeline)
      pipeline['stages'].map { |s| "#{pipeline['pipeline']} :: #{s}" }
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
gocd_pre_push-2.1 lib/gocd_pre_push/build_informer.rb
gocd_pre_push-2.0.3 lib/gocd_pre_push/build_informer.rb
gocd_pre_push-2.0.2 lib/gocd_pre_push/build_informer.rb
gocd_pre_push-2.0 lib/gocd_pre_push/build_informer.rb