diff options
author | Azul <azul@riseup.net> | 2017-07-17 20:51:46 +0200 |
---|---|---|
committer | Varac <varac@leap.se> | 2017-10-16 13:20:42 +0200 |
commit | 90be5e3859fbdd02202720716894b6b5261ab0e3 (patch) | |
tree | ce755b308f46dba10532d947363f373ef5c167b5 /jobs/gitlab_build_status.rb | |
parent | d8e6b9f73339b5e73f77a418c1ba1a3206393e73 (diff) |
feat: only alert for failing master builds
Diffstat (limited to 'jobs/gitlab_build_status.rb')
-rw-r--r-- | jobs/gitlab_build_status.rb | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/jobs/gitlab_build_status.rb b/jobs/gitlab_build_status.rb index be52f98..317118d 100644 --- a/jobs/gitlab_build_status.rb +++ b/jobs/gitlab_build_status.rb @@ -14,18 +14,20 @@ SCHEDULER.every '3000s', :first_in => 0 do # get a list of all projects projects = Gitlab.group(ENV['GITLAB_GROUP_ID']).projects.map do |proj| - { :id => proj['id'], :name => proj['name'], :path => proj['path_with_namespace'] } + { :id => proj['id'], :name => proj['name'], :path => proj['path_with_namespace'], + :default_branch => proj['default_branch']} end projects.each do |proj| - begin - pipeline = Gitlab.pipelines(proj[:id], { per_page: 1 }) + pipelines = Gitlab.pipelines(proj[:id], { per_page: 10 }) #pp pipeline[0] - proj[:status] = pipeline[0].status - proj[:pipeline_id] = pipeline[0].id - proj[:ref] = pipeline[0].ref - date = DateTime.parse(pipeline[0].updated_at).strftime("%F %T") + pipeline = pipelines.find{|p| p.ref == proj[:default_branch]} + next if pipeline.nil? + proj[:status] = pipeline.status + proj[:pipeline_id] = pipeline.id + proj[:ref] = pipeline.ref + date = DateTime.parse(pipeline.updated_at).strftime("%F %T") proj[:date] = date rescue proj[:status] = 'No builds configured' @@ -34,7 +36,7 @@ SCHEDULER.every '3000s', :first_in => 0 do unless proj[:status] =~ /^success|running|No builds configured$/ broken_builds << proj end - #puts proj + puts proj end failed = broken_builds.size > 0 |