sensu-plugins-jenkins 1.2.0 → 1.3.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 64b5b8a76d01460965176f93d822b9cdc785bd76
4
- data.tar.gz: 79716dccf7d33ae4647d189650d2b58365633e15
3
+ metadata.gz: a0ca38a46f4172586e2d186966e9e0f5966f18be
4
+ data.tar.gz: 58da9a11a763e44673a1c703177ffb016b678283
5
5
  SHA512:
6
- metadata.gz: 85ac99750ad5ca0763e2c6d5d2b406bf8d1a7f96b3abc6f70c3fa8c61d0991591481038d3a4f7d7dd0412db2345cbde4dd8c529c75d893cff3d00257aaab2b4f
7
- data.tar.gz: e5d326f19100d1af096927a8bf422d1523d6129deb37a182eb706d35cf53391838f3fd1fd7b83b78f4c09ab60bce20204ea1211f6fcf06026d0d90de4db8dfc5
6
+ metadata.gz: e67ddbe8b75ecf76bcf9286cf9bfd950e48abf3472f8dd46b51d8295abcef8cd47051fbaf72e591dd96d979a2d24b83f3bf3aea665c7bcf05de27240fbab1203
7
+ data.tar.gz: e418d73135095b7b54d63cde12596bcd5bcfc08c78c9151ba984990307ab44578444a7d0d024495d3f22f84ac4265b31d23f3696728e9bfb1725ea46bf6386c8
@@ -4,6 +4,9 @@ This project adheres to [Semantic Versioning](http://semver.org/).
4
4
  This CHANGELOG follows the format listed at [Keep A Changelog](http://keepachangelog.com/)
5
5
 
6
6
  ## [Unreleased]
7
+ ## [1.3.0] - 2017-05-04
8
+ ### Added
9
+ - Additional parameter -w to report unstable jobs as a Sensu warning
7
10
 
8
11
  ## [1.2.0] - 2016-11-11
9
12
  ### Added
@@ -56,7 +59,8 @@ This CHANGELOG follows the format listed at [Keep A Changelog](http://keepachang
56
59
  ### Added
57
60
  - initial release
58
61
 
59
- [Unreleased]: https://github.com/sensu-plugins/sensu-plugins-jenkins/compare/1.2.0...HEAD
62
+ [Unreleased]: https://github.com/sensu-plugins/sensu-plugins-jenkins/compare/1.3.0...HEAD
63
+ [1.3.0]: https://github.com/sensu-plugins/sensu-plugins-jenkins/compare/1.2.0...1.3.0
60
64
  [1.2.0]: https://github.com/sensu-plugins/sensu-plugins-jenkins/compare/1.1.0...1.2.0
61
65
  [1.1.0]: https://github.com/sensu-plugins/sensu-plugins-jenkins/compare/1.0.0...1.1.0
62
66
  [1.0.0]: https://github.com/sensu-plugins/sensu-plugins-jenkins/compare/0.1.0...1.0.0
@@ -66,11 +66,21 @@ class JenkinsJobChecker < Sensu::Plugin::Check::CLI
66
66
  required: false,
67
67
  default: ENV['JENKINS_PASS']
68
68
 
69
+ option :include_warnings,
70
+ description: 'whether to report unstable jobs as a warning',
71
+ short: '-w',
72
+ long: '--include-warnings',
73
+ boolean: true,
74
+ required: false,
75
+ default: false
76
+
69
77
  def run
70
78
  if failed_jobs.any?
71
- critical "Jobs reporting failure: #{failed_jobs_names}"
79
+ critical "Jobs reporting failure: #{failed_job_names}, jobs reported as unstable: #{unstable_job_names}"
80
+ elsif unstable_jobs.any? && config[:include_warnings]
81
+ warning "Jobs reported as unstable: #{unstable_job_names}"
72
82
  else
73
- ok 'All queried jobs reports success'
83
+ ok 'All queried jobs report success'
74
84
  end
75
85
  end
76
86
 
@@ -85,15 +95,15 @@ class JenkinsJobChecker < Sensu::Plugin::Check::CLI
85
95
  end
86
96
 
87
97
  def jobs_statuses
88
- if config[:job_list] =~ /\^/
89
- # #YELLOW
90
- jenkins_api_client.job.list(config[:job_list]).reduce({}) do |listing, job_name| # rubocop:disable Style/EachWithObject
91
- listing[job_name] = job_status(job_name)
92
- listing
98
+ @job_listing ||=
99
+ if config[:job_list] =~ /\^/
100
+ jenkins_api_client.job.list(config[:job_list]).reduce({}) do |listing, job_name| # rubocop:disable Style/EachWithObject
101
+ listing[job_name] = job_status(job_name)
102
+ listing
103
+ end
104
+ else
105
+ { config[:job_list] => job_status(config[:job_list]) }
93
106
  end
94
- else
95
- { config[:job_list] => job_status(config[:job_list]) }
96
- end
97
107
  end
98
108
 
99
109
  def job_status(job_name)
@@ -109,11 +119,19 @@ class JenkinsJobChecker < Sensu::Plugin::Check::CLI
109
119
  critical "Error looking up Jenkins job: #{job_name}"
110
120
  end
111
121
 
122
+ def unstable_jobs
123
+ jobs_statuses.select { |_job_name, status| status == 'unstable' }
124
+ end
125
+
112
126
  def failed_jobs
113
127
  jobs_statuses.select { |_job_name, status| status == 'failure' }
114
128
  end
115
129
 
116
- def failed_jobs_names
130
+ def unstable_job_names
131
+ unstable_jobs.keys.join(', ')
132
+ end
133
+
134
+ def failed_job_names
117
135
  failed_jobs.keys.join(', ')
118
136
  end
119
137
  end
@@ -60,7 +60,8 @@ class JenkinsMetricsPingPongChecker < Sensu::Plugin::Check::CLI
60
60
 
61
61
  def run
62
62
  https ||= config[:https] ? 'https' : 'http'
63
- r = RestClient::Resource.new("#{https}://#{config[:server]}:#{config[:port]}#{config[:uri]}", timeout: 5).get
63
+ testurl = "#{https}://#{config[:server]}:#{config[:port]}#{config[:uri]}"
64
+ r = RestClient::Resource.new(testurl, timeout: 5).get
64
65
  if r.code == 200 && r.body.include?('pong')
65
66
  ok 'Jenkins Service is up'
66
67
  else
@@ -1,7 +1,7 @@
1
1
  module SensuPluginsJenkins
2
2
  module Version
3
3
  MAJOR = 1
4
- MINOR = 2
4
+ MINOR = 3
5
5
  PATCH = 0
6
6
 
7
7
  VER_STRING = [MAJOR, MINOR, PATCH].compact.join('.')
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sensu-plugins-jenkins
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.0
4
+ version: 1.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sensu-Plugins and contributors
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-11-12 00:00:00.000000000 Z
11
+ date: 2017-05-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: sensu-plugin