diff options
author | Azul <azul@riseup.net> | 2017-07-17 20:51:46 +0200 |
---|---|---|
committer | Azul <azul@riseup.net> | 2017-07-17 20:51:46 +0200 |
commit | 6193bef96b118ca099c6a03bbe6403e0d4acd1ff (patch) | |
tree | 5a2db1a7370b45dd271eceffa1629399c66115d5 /jobs | |
parent | 94e3b2ba1fe499dcb0e8e7ee10e1d2caaa806091 (diff) |
feat: only alert for failing master builds
Diffstat (limited to 'jobs')
-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 |