Sha256: 11d41da33247eb25489b5bed54638fec80bb8947baf2d19f9944bc9917ba7b5f

Contents?: true

Size: 924 Bytes

Versions: 1

Compression:

Stored size: 924 Bytes

Contents

#!/usr/bin/env ruby
# frozen_string_literal: true

$LOAD_PATH.unshift File.expand_path('../lib', __dir__)

require 'concourse'
require 'bitbar'

client = Concourse::Client.new(
  ENV.fetch('CONCOURSE_URI'),
  username: ENV['CONCOURSE_USER'],
  password: ENV['CONCOURSE_PASSWORD']
)

target_name = ENV.fetch('CONCOURSE_TARGET', 'Concourse')
ci = Concourse::Target.new(client)

begin
  pipelines = ci.pipelines
rescue StandardError => e
  warn Bitbar::Concourse::ErrorPresenter.new(e, target_name)
  exit 1
end

pipelines = pipelines.select { |pipeline| ARGV.include?(pipeline.name) } if ARGV.any?

latest_builds = pipelines.map do |pipeline|
  pipeline.jobs.map do |job|
    if build = job.finished_build
      Bitbar::Concourse::BuildPresenter.new(build)
    end
  end
end.flatten.compact.sort_by!(&:end_time).reverse

puts Bitbar::Concourse::AggregatePresenter.new(latest_builds, target_name)
puts '---'
puts latest_builds

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
bitbar-concourse-1.1 exe/bitbar-concourse