summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAzul <azul@riseup.net>2017-07-17 20:51:46 +0200
committerVarac <varac@leap.se>2017-10-16 13:20:42 +0200
commit90be5e3859fbdd02202720716894b6b5261ab0e3 (patch)
treece755b308f46dba10532d947363f373ef5c167b5
parentd8e6b9f73339b5e73f77a418c1ba1a3206393e73 (diff)
feat: only alert for failing master builds
-rw-r--r--Gemfile3
-rw-r--r--Gemfile.lock16
-rw-r--r--jobs/gitlab_build_status.rb18
3 files changed, 16 insertions, 21 deletions
diff --git a/Gemfile b/Gemfile
index 08e8f3f..a1601d1 100644
--- a/Gemfile
+++ b/Gemfile
@@ -1,5 +1,5 @@
source 'https://rubygems.org'
-gem 'gitlab', :git => 'https://github.com/varac/gitlab.git', :branch => 'pipeline_support'
+gem 'gitlab'
# activesupport >= 5.0.0 requires ruby 2.2 which break jessie support
gem 'activesupport', '< 5.0.0'
# both following gems will break on jessie with
@@ -8,7 +8,6 @@ gem 'activesupport', '< 5.0.0'
gem 'mime-types', '2.6.2'
gem 'rest-client', '< 2.0.0'
-
gemspec
gem "nagiosharder"
diff --git a/Gemfile.lock b/Gemfile.lock
index f541e3d..9629ed0 100644
--- a/Gemfile.lock
+++ b/Gemfile.lock
@@ -1,12 +1,3 @@
-GIT
- remote: https://github.com/varac/gitlab.git
- revision: a2d105128aab0226082bbdabf7da0e24892e5b79
- branch: pipeline_support
- specs:
- gitlab (3.7.0)
- httparty
- terminal-table
-
PATH
remote: .
specs:
@@ -48,6 +39,9 @@ GEM
eventmachine (1.2.0.1)
execjs (2.0.2)
fakeweb (1.3.0)
+ gitlab (4.2.0)
+ httparty
+ terminal-table
haml (4.0.7)
tilt
hashie (1.2.0)
@@ -137,7 +131,7 @@ DEPENDENCIES
activesupport (< 5.0.0)
dashing!
fakeweb (~> 1.3.0)
- gitlab!
+ gitlab
haml (~> 4.0.4)
mime-types (= 2.6.2)
minitest (~> 5.2.0)
@@ -147,4 +141,4 @@ DEPENDENCIES
simplecov (~> 0.8.2)
BUNDLED WITH
- 1.11.2
+ 1.14.6
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