leeroy 0.1 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +20 -0
- data/Gemfile +4 -0
- data/Gemfile.lock +31 -0
- data/LICENSE.txt +22 -0
- data/README.md +1 -1
- data/Rakefile +2 -0
- data/bin/leeroy +2 -103
- data/leeroy.gemspec +29 -0
- data/lib/leeroy.rb +3 -0
- data/lib/leeroy/jenkins.rb +111 -0
- data/lib/leeroy/version.rb +3 -0
- metadata +123 -17
- data/LICENSE +0 -17
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 636a8cd002e62972e2a97d3a609c3b62c77ba844
|
4
|
+
data.tar.gz: 34a1fa01af2133f94c0e17d3c2f9d8d59b0e9492
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 3ed1fda82ea19330662fb127bcb9ea4ed5135ae928139e46f356e83254df868cfc5c379b7cba5df0a04d6e68826181c474d17a5695b4729d3a776a1ced42551c
|
7
|
+
data.tar.gz: 7698dc9c8d6bb23b3eb21f83375201d464964575af5ce85b157d0c33d836213863fc6136a942b4bf8a381065e3161ce7b7235652d6faf5f7aee54a3dc1a2ca44
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
leeroy (0.1.0)
|
5
|
+
paint (~> 0.8)
|
6
|
+
rest-client (~> 1.7)
|
7
|
+
terminal-table (~> 1.4)
|
8
|
+
trollop (~> 2.0)
|
9
|
+
|
10
|
+
GEM
|
11
|
+
remote: https://rubygems.org/
|
12
|
+
specs:
|
13
|
+
gem-release (0.7.3)
|
14
|
+
mime-types (2.4.3)
|
15
|
+
netrc (0.10.2)
|
16
|
+
paint (0.9.0)
|
17
|
+
rake (10.4.2)
|
18
|
+
rest-client (1.7.3)
|
19
|
+
mime-types (>= 1.16, < 3.0)
|
20
|
+
netrc (~> 0.7)
|
21
|
+
terminal-table (1.4.5)
|
22
|
+
trollop (2.1.1)
|
23
|
+
|
24
|
+
PLATFORMS
|
25
|
+
ruby
|
26
|
+
|
27
|
+
DEPENDENCIES
|
28
|
+
bundler (~> 1.7)
|
29
|
+
gem-release (~> 0.7)
|
30
|
+
leeroy!
|
31
|
+
rake (~> 10.0)
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2014 John Hamelink
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
CHANGED
data/Rakefile
ADDED
data/bin/leeroy
CHANGED
@@ -1,105 +1,4 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
|
+
require 'leeroy'
|
2
3
|
|
3
|
-
|
4
|
-
require "bundler/setup"
|
5
|
-
|
6
|
-
require 'paint'
|
7
|
-
require 'terminal-table'
|
8
|
-
require 'rest-client'
|
9
|
-
require 'json'
|
10
|
-
require 'uri'
|
11
|
-
require 'trollop'
|
12
|
-
|
13
|
-
|
14
|
-
def makeResource(route)
|
15
|
-
route = URI.escape(route)
|
16
|
-
return RestClient::Resource.new @endpoint + '/' + route + '/api/json', @username, @password
|
17
|
-
end
|
18
|
-
|
19
|
-
|
20
|
-
def getJobs()
|
21
|
-
resource = makeResource('/')
|
22
|
-
return JSON.parse(resource.get)['jobs']
|
23
|
-
end
|
24
|
-
|
25
|
-
def getJob(name)
|
26
|
-
resource = makeResource('job/' + name)
|
27
|
-
return JSON.parse(resource.get)
|
28
|
-
end
|
29
|
-
|
30
|
-
def list()
|
31
|
-
jobs = getJobs()
|
32
|
-
|
33
|
-
rows = []
|
34
|
-
jobs.each do |job|
|
35
|
-
rows << [job['name'], getJobStatus(job["name"])]
|
36
|
-
end
|
37
|
-
|
38
|
-
header = ['Job', {:value => 'Status', :alignment => :center}]
|
39
|
-
table = Terminal::Table.new :headings => header, :rows => rows
|
40
|
-
table.align_column(1, :center)
|
41
|
-
print table
|
42
|
-
end
|
43
|
-
|
44
|
-
def getJobStatus(name, prefix = "", suffix = "")
|
45
|
-
score = getJob(name)['healthReport']
|
46
|
-
unless score == []
|
47
|
-
score = score[0]['score']
|
48
|
-
|
49
|
-
if score > 80
|
50
|
-
return Paint[score.to_s + '%', :black, :green, :bright]
|
51
|
-
elsif score > 60 && score < 80
|
52
|
-
return Paint[score.to_s + '%', :yellow, :bright]
|
53
|
-
elsif score > 40 && score < 60
|
54
|
-
return Paint[score.to_s + '%', :orange, :bright]
|
55
|
-
elsif score > 20 && score < 40
|
56
|
-
return Paint[score.to_s + '%', :orange, :bright, :red]
|
57
|
-
elsif score < 20
|
58
|
-
return Paint[score.to_s + '%', :white, :bright, :red]
|
59
|
-
else
|
60
|
-
return Paint["Error", :white, :bright, :red]
|
61
|
-
end
|
62
|
-
|
63
|
-
end
|
64
|
-
|
65
|
-
return Paint["No Results", :white, :bright, :black]
|
66
|
-
end
|
67
|
-
|
68
|
-
|
69
|
-
opts = Trollop::options do
|
70
|
-
version "Leeroy 0.0.1 (c) 2012 John Hamelink <john@johnhamelink.com>"
|
71
|
-
banner <<-EOS
|
72
|
-
|
73
|
-
Leeeeeeeeeeeeeeeeroy Jenkins!
|
74
|
-
|
75
|
-
Leeroy lets you quickly check the status of your builds from the commandline.
|
76
|
-
Leeroy is called Leeroy because of this excellent meme: http://youtu.be/LkCNJRfSZBU
|
77
|
-
|
78
|
-
Usage:
|
79
|
-
------
|
80
|
-
|
81
|
-
leeroy --username john@doe.com --password p455w0rd --endpoint http://jenkins.dev:8080
|
82
|
-
|
83
|
-
Options:
|
84
|
-
--------
|
85
|
-
|
86
|
-
EOS
|
87
|
-
opt :username, "Your Jenkins username", :type => :string
|
88
|
-
opt :password, "Your Jenkins password", :type => :string
|
89
|
-
opt :endpoint, "The root URL of jenkins", :type => :string
|
90
|
-
end
|
91
|
-
|
92
|
-
|
93
|
-
Trollop::die :username, "must be defined" unless opts[:username]
|
94
|
-
Trollop::die :password, "must be defined" unless opts[:password]
|
95
|
-
Trollop::die :endpoint, "must be defined" unless opts[:endpoint]
|
96
|
-
|
97
|
-
|
98
|
-
@username = opts[:username]
|
99
|
-
@password = opts[:password]
|
100
|
-
@endpoint = opts[:endpoint]
|
101
|
-
|
102
|
-
|
103
|
-
print "\n\n"
|
104
|
-
list()
|
105
|
-
print "\n\n"
|
4
|
+
Leeroy::Jenkins.new
|
data/leeroy.gemspec
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'leeroy/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "leeroy"
|
8
|
+
spec.version = Leeroy::VERSION
|
9
|
+
spec.authors = ["John Hamelink"]
|
10
|
+
spec.email = ["hello@farmer.io"]
|
11
|
+
spec.summary = %q{Quickly see the status of your jenkins jobs}
|
12
|
+
spec.description = %q{Leeroy lets you quickly check the status of your jenkins builds from the commandline.}
|
13
|
+
spec.homepage = "https://github.com/johnhamelink/leeroy"
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files -z`.split("\x0")
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_dependency "paint", "~> 0.8"
|
22
|
+
spec.add_dependency "rest-client", "~> 1.7"
|
23
|
+
spec.add_dependency "trollop", "~> 2.0"
|
24
|
+
spec.add_dependency "terminal-table", "~> 1.4"
|
25
|
+
|
26
|
+
spec.add_development_dependency "gem-release", "~> 0.7"
|
27
|
+
spec.add_development_dependency "bundler", "~> 1.7"
|
28
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
29
|
+
end
|
data/lib/leeroy.rb
ADDED
@@ -0,0 +1,111 @@
|
|
1
|
+
module Leeroy
|
2
|
+
|
3
|
+
require 'paint'
|
4
|
+
require 'terminal-table'
|
5
|
+
require 'rest-client'
|
6
|
+
require 'json'
|
7
|
+
require 'uri'
|
8
|
+
require 'trollop'
|
9
|
+
|
10
|
+
class Jenkins
|
11
|
+
|
12
|
+
def initialize
|
13
|
+
|
14
|
+
opts = Trollop::options do
|
15
|
+
version "Leeroy #{Leeroy::VERSION} (c) 2012 John Hamelink <john@johnhamelink.com>"
|
16
|
+
banner <<-EOS
|
17
|
+
|
18
|
+
Leeeeeeeeeeeeeeeeroy Jenkins!
|
19
|
+
|
20
|
+
Leeroy lets you quickly check the status of your builds from the commandline.
|
21
|
+
Leeroy is called Leeroy because of this excellent meme: http://youtu.be/LkCNJRfSZBU
|
22
|
+
|
23
|
+
Usage:
|
24
|
+
------
|
25
|
+
|
26
|
+
leeroy --username john@doe.com --password p455w0rd --endpoint http://jenkins.dev:8080
|
27
|
+
|
28
|
+
Options:
|
29
|
+
--------
|
30
|
+
|
31
|
+
EOS
|
32
|
+
opt :username, "Your Jenkins username", :type => :string
|
33
|
+
opt :password, "Your Jenkins password", :type => :string
|
34
|
+
opt :endpoint, "The root URL of jenkins", :type => :string
|
35
|
+
end
|
36
|
+
|
37
|
+
|
38
|
+
Trollop::die :username, "must be defined" unless opts[:username]
|
39
|
+
Trollop::die :password, "must be defined" unless opts[:password]
|
40
|
+
Trollop::die :endpoint, "must be defined" unless opts[:endpoint]
|
41
|
+
|
42
|
+
|
43
|
+
@username = opts[:username]
|
44
|
+
@password = opts[:password]
|
45
|
+
@endpoint = opts[:endpoint]
|
46
|
+
|
47
|
+
|
48
|
+
print "\n\n"
|
49
|
+
list
|
50
|
+
print "\n\n"
|
51
|
+
end
|
52
|
+
|
53
|
+
private
|
54
|
+
|
55
|
+
def makeResource(route)
|
56
|
+
route = URI.escape(route)
|
57
|
+
return RestClient::Resource.new @endpoint + '/' + route + '/api/json', @username, @password
|
58
|
+
end
|
59
|
+
|
60
|
+
|
61
|
+
def getJobs()
|
62
|
+
resource = makeResource('/')
|
63
|
+
return JSON.parse(resource.get)['jobs']
|
64
|
+
end
|
65
|
+
|
66
|
+
def getJob(name)
|
67
|
+
resource = makeResource('job/' + name)
|
68
|
+
return JSON.parse(resource.get)
|
69
|
+
end
|
70
|
+
|
71
|
+
def list()
|
72
|
+
jobs = getJobs()
|
73
|
+
|
74
|
+
rows = []
|
75
|
+
jobs.each do |job|
|
76
|
+
rows << [job['name'], getJobStatus(job["name"])]
|
77
|
+
end
|
78
|
+
|
79
|
+
header = ['Job', {:value => 'Status', :alignment => :center}]
|
80
|
+
table = Terminal::Table.new :headings => header, :rows => rows
|
81
|
+
table.align_column(1, :center)
|
82
|
+
print table
|
83
|
+
end
|
84
|
+
|
85
|
+
def getJobStatus(name, prefix = "", suffix = "")
|
86
|
+
score = getJob(name)['healthReport']
|
87
|
+
unless score == []
|
88
|
+
score = score[0]['score']
|
89
|
+
|
90
|
+
if score > 80
|
91
|
+
return Paint[score.to_s + '%', :black, :green, :bright]
|
92
|
+
elsif score > 60 && score < 80
|
93
|
+
return Paint[score.to_s + '%', :yellow, :bright]
|
94
|
+
elsif score > 40 && score < 60
|
95
|
+
return Paint[score.to_s + '%', :orange, :bright]
|
96
|
+
elsif score > 20 && score < 40
|
97
|
+
return Paint[score.to_s + '%', :orange, :bright, :red]
|
98
|
+
elsif score < 20
|
99
|
+
return Paint[score.to_s + '%', :white, :bright, :red]
|
100
|
+
else
|
101
|
+
return Paint["Error", :white, :bright, :red]
|
102
|
+
end
|
103
|
+
|
104
|
+
end
|
105
|
+
|
106
|
+
return Paint["No Results", :white, :bright, :black]
|
107
|
+
end
|
108
|
+
|
109
|
+
|
110
|
+
end
|
111
|
+
end
|
metadata
CHANGED
@@ -1,49 +1,155 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: leeroy
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
5
|
-
prerelease:
|
4
|
+
version: 0.1.1
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- John Hamelink
|
9
8
|
autorequire:
|
10
9
|
bindir: bin
|
11
10
|
cert_chain: []
|
12
|
-
date:
|
13
|
-
dependencies:
|
14
|
-
|
11
|
+
date: 2015-02-24 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: paint
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0.8'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0.8'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rest-client
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '1.7'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '1.7'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: trollop
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '2.0'
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '2.0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: terminal-table
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '1.4'
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '1.4'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: gem-release
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0.7'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0.7'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: bundler
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - "~>"
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '1.7'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - "~>"
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '1.7'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: rake
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - "~>"
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '10.0'
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - "~>"
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '10.0'
|
111
|
+
description: Leeroy lets you quickly check the status of your jenkins builds from
|
112
|
+
the commandline.
|
15
113
|
email:
|
16
|
-
-
|
114
|
+
- hello@farmer.io
|
17
115
|
executables:
|
18
116
|
- leeroy
|
19
117
|
extensions: []
|
20
118
|
extra_rdoc_files: []
|
21
119
|
files:
|
22
|
-
-
|
23
|
-
-
|
120
|
+
- ".gitignore"
|
121
|
+
- Gemfile
|
122
|
+
- Gemfile.lock
|
123
|
+
- LICENSE.txt
|
24
124
|
- README.md
|
125
|
+
- Rakefile
|
126
|
+
- bin/leeroy
|
127
|
+
- leeroy.gemspec
|
128
|
+
- lib/leeroy.rb
|
129
|
+
- lib/leeroy/jenkins.rb
|
130
|
+
- lib/leeroy/version.rb
|
25
131
|
homepage: https://github.com/johnhamelink/leeroy
|
26
|
-
licenses:
|
132
|
+
licenses:
|
133
|
+
- MIT
|
134
|
+
metadata: {}
|
27
135
|
post_install_message:
|
28
136
|
rdoc_options: []
|
29
137
|
require_paths:
|
30
138
|
- lib
|
31
139
|
required_ruby_version: !ruby/object:Gem::Requirement
|
32
|
-
none: false
|
33
140
|
requirements:
|
34
|
-
- -
|
141
|
+
- - ">="
|
35
142
|
- !ruby/object:Gem::Version
|
36
143
|
version: '0'
|
37
144
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
38
|
-
none: false
|
39
145
|
requirements:
|
40
|
-
- -
|
146
|
+
- - ">="
|
41
147
|
- !ruby/object:Gem::Version
|
42
|
-
version:
|
148
|
+
version: '0'
|
43
149
|
requirements: []
|
44
|
-
rubyforge_project:
|
45
|
-
rubygems_version:
|
150
|
+
rubyforge_project:
|
151
|
+
rubygems_version: 2.4.5
|
46
152
|
signing_key:
|
47
|
-
specification_version:
|
153
|
+
specification_version: 4
|
48
154
|
summary: Quickly see the status of your jenkins jobs
|
49
155
|
test_files: []
|
data/LICENSE
DELETED
@@ -1,17 +0,0 @@
|
|
1
|
-
Copyright 2012 John Hamelink <john@johnhamelink.com>
|
2
|
-
|
3
|
-
This file is part of Leeroy.
|
4
|
-
|
5
|
-
Leeroy is free software: you can redistribute it and/or modify
|
6
|
-
it under the terms of the GNU General Public License as published by
|
7
|
-
the Free Software Foundation, either version 3 of the License, or
|
8
|
-
(at your option) any later version.
|
9
|
-
|
10
|
-
Leeroy is distributed in the hope that it will be useful,
|
11
|
-
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
12
|
-
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
13
|
-
GNU General Public License for more details.
|
14
|
-
|
15
|
-
You should have received a copy of the GNU General Public License
|
16
|
-
along with Leeroy. If not, see <http://www.gnu.org/licenses/>.
|
17
|
-
|