summaryrefslogtreecommitdiff
path: root/jobs/gitlab_build_status.rb
blob: 57fe0b0ff99c6d117e2c5a594ff76b445dd45a9b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
require 'gitlab_stats'


SCHEDULER.every '120s', :first_in => 0 do
  broken_builds = []
  started = Time.now

  GitlabStats.projects.each do |proj|
    next if proj[:archived]
    next unless proj[:builds_enabled]
    GitlabStats.add_pipeline_stats_to proj

    puts "#{Time.now} gitlab: #{proj[:name]} (#{proj[:ref]}): #{proj[:status]}"
    unless proj[:status] =~ /^success|running|No builds configured/
      broken_builds << proj
    end
  end

  failed = broken_builds.size > 0

  send_event('gitlab-builds', { failed: failed, header: "Gitlab builds", broken_builds: broken_builds })
  puts "#{Time.now} gitlab: Going through all projects took: #{Time.now - started}."
end