ci-go-nfo 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +13 -0
- data/{README.md → README} +22 -1
- data/bin/ci-go-nfo +42 -26
- data/lib/ci-go-nfo.rb +45 -13
- data/lib/ci-go-nfo/cctray.rb +2 -2
- data/lib/ci-go-nfo/print.rb +31 -0
- data/lib/ci-go-nfo/version.rb +1 -1
- data/lib/ci-go-nfo/www.rb +19 -6
- data/resource/config.store +1 -1
- metadata +5 -3
data/CHANGELOG
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
Ci-Go-Nfo CHANGLEOG
|
2
|
+
++++++++++++++++++++++++++++++++++++++++++++++++++
|
3
|
+
|
4
|
+
v0.0.1 => v0.0.2
|
5
|
+
5) get summary of total/passed/failed Go CI pipelines and the names of failed
|
6
|
+
|
7
|
+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
8
|
+
|
9
|
+
v0.0.0 => v0.0.1
|
10
|
+
1) setup config for ci-go-nfo
|
11
|
+
2) get information for all builds in Go CI
|
12
|
+
3) get information of just passed Go CI builds
|
13
|
+
4) get information of just failed Go CI builds
|
data/{README.md → README}
RENAMED
@@ -14,7 +14,28 @@ easily from console itself, no more browse
|
|
14
14
|
|
15
15
|
## Usage
|
16
16
|
|
17
|
-
|
17
|
+
Ci-Go-Nfo ver.0.0.1
|
18
|
+
|
19
|
+
to set-up credential config for your go-ci
|
20
|
+
$ ci-go-nfo setup
|
21
|
+
|
22
|
+
to set-up credential config for your go-ci
|
23
|
+
$ ci-go-nfo setup
|
24
|
+
|
25
|
+
to show go-ci info of all runs
|
26
|
+
$ ci-go-nfo
|
27
|
+
|
28
|
+
to show go-ci summary of total/passed/failed pipelines
|
29
|
+
$ ci-go-nfo summary
|
30
|
+
|
31
|
+
to show go-ci info of failed runs
|
32
|
+
$ ci-go-nfo fail
|
33
|
+
|
34
|
+
to show go-ci info of passed runs
|
35
|
+
$ ci-go-nfo pass
|
36
|
+
_____
|
37
|
+
.....more to come
|
38
|
+
|
18
39
|
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
19
40
|
|
20
41
|
## Contributing
|
data/bin/ci-go-nfo
CHANGED
@@ -3,30 +3,46 @@ $LOAD_PATH.unshift File.dirname(__FILE__) + '/../lib'
|
|
3
3
|
|
4
4
|
require 'ci-go-nfo'
|
5
5
|
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
6
|
+
if ARGV.size === 1
|
7
|
+
case ARGV[0]
|
8
|
+
when 'help', '-h', '--help', '?'
|
9
|
+
puts <<-HELP
|
10
|
+
\e[1m\e[31mCi-Go-Nfo ver.#{Ci::Go::Nfo::VERSION}\e[0m
|
11
|
+
to set-up credential config for your go-ci\e[33m
|
12
|
+
$ ci-go-nfo setup\e[0m
|
13
|
+
to show go-ci info of all runs\e[33m
|
14
|
+
$ ci-go-nfo\e[0m
|
15
|
+
to show go-ci info of failed runs\e[33m
|
16
|
+
$ ci-go-nfo fail\e[0m
|
17
|
+
to show go-ci info of passed runs\e[33m
|
18
|
+
$ ci-go-nfo pass\e[0m
|
19
|
+
\e[32m_____
|
20
|
+
\e[33m.....more to come
|
21
|
+
\e[0m
|
22
|
+
HELP
|
23
|
+
when 'setup'
|
24
|
+
Ci::Go::Access.persist_config
|
25
|
+
when nil
|
26
|
+
Ci::Go::Nfo.builds
|
27
|
+
when 'pass'
|
28
|
+
Ci::Go::Nfo.builds 'pass'
|
29
|
+
when 'fail'
|
30
|
+
Ci::Go::Nfo.builds 'fail'
|
31
|
+
when 'summary'
|
32
|
+
Ci::Go::Nfo.summary
|
33
|
+
else
|
34
|
+
Ci::Go::Nfo.builds nil, ARGV[0]
|
35
|
+
end
|
36
|
+
|
37
|
+
elsif ARGV.size === 2
|
38
|
+
argv = ARGV
|
39
|
+
status = ['pass', 'fail']
|
40
|
+
detail = ['dep', 'history']
|
41
|
+
filter = [status, detail].flatten.select{|s| argv.delete status}
|
42
|
+
|
43
|
+
if status.include? filter
|
44
|
+
Ci::Go::Nfo.builds filter, argv
|
45
|
+
elsif filter === 'dep'
|
46
|
+
# would
|
47
|
+
end
|
32
48
|
end
|
data/lib/ci-go-nfo.rb
CHANGED
@@ -10,26 +10,58 @@ module Ci
|
|
10
10
|
module Go
|
11
11
|
module Nfo
|
12
12
|
|
13
|
-
def self.
|
13
|
+
def self.summary
|
14
|
+
go_all = Ci::Go::Cctray.data_from_xml
|
15
|
+
failed_builds, passed_builds = [], []
|
16
|
+
go_all['names'].each_with_index do |name, idx|
|
17
|
+
if name.split('::').size == 3
|
18
|
+
if go_all['lastBuildStatus'][idx] === 'Failure'
|
19
|
+
failed_builds << name.split('::')[0]
|
20
|
+
elsif go_all['lastBuildStatus'][idx] === 'Success'
|
21
|
+
passed_builds << name.split('::')[0]
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
Ci::Go::Print.summary passed_builds.uniq, failed_builds.uniq
|
26
|
+
end
|
27
|
+
|
28
|
+
def self.builds(status = nil)
|
14
29
|
go = Ci::Go::Cctray.data_from_xml
|
15
30
|
go['names'].each_with_index do |name, idx|
|
16
31
|
next if name.split('::').size < 3
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
elsif
|
28
|
-
|
32
|
+
build = {
|
33
|
+
'name' => name,
|
34
|
+
'last_status' => go['lastBuildStatus'][idx],
|
35
|
+
'last_label' => go['lastBuildLabels'][idx],
|
36
|
+
'last_time' => go['lastBuildTimes'][idx],
|
37
|
+
'weburl' => go['weburls'][idx]
|
38
|
+
}
|
39
|
+
|
40
|
+
if status.nil?
|
41
|
+
Ci::Go::Print.build_status build
|
42
|
+
elsif status === 'fail' && build['last_status'] === 'Failure'
|
43
|
+
Ci::Go::Print.build_status build
|
44
|
+
elsif status === 'pass' && build['last_status'] === 'Success'
|
45
|
+
Ci::Go::Print.build_status build
|
29
46
|
end
|
30
47
|
end
|
31
48
|
end
|
32
49
|
|
50
|
+
def self.build_of(pipeline)
|
51
|
+
go = Ci::Go::Cctray.data_from_xml
|
52
|
+
build_name = go['names'].select{|gname| gname.split(/::/)[0] === pipeline}
|
53
|
+
idx = go.index build_name
|
54
|
+
build = {
|
55
|
+
'name' => go['names'][idx],
|
56
|
+
'last_status' => go['lastBuildStatus'][idx],
|
57
|
+
'last_label' => go['lastBuildLabels'][idx],
|
58
|
+
'last_time' => go['lastBuildTimes'][idx],
|
59
|
+
'weburl' => go['weburls'][idx]
|
60
|
+
}
|
61
|
+
|
62
|
+
Ci::Go::Print.build_status build
|
63
|
+
end
|
64
|
+
|
33
65
|
end
|
34
66
|
end
|
35
67
|
end
|
data/lib/ci-go-nfo/cctray.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
## cctray.rb
|
2
|
+
# Ci::Go::Cctray.data_from_xml ~ return hash of array of fields in Go CCTray XML
|
2
3
|
|
3
4
|
require 'xml-motor'
|
4
5
|
|
@@ -7,7 +8,7 @@ module Ci
|
|
7
8
|
module Cctray
|
8
9
|
|
9
10
|
def self.data_from_xml
|
10
|
-
cctray = Ci::WWW.
|
11
|
+
cctray = Ci::WWW::Go.cctray_xml
|
11
12
|
splitd = XMLMotor.splitter cctray.body
|
12
13
|
tags = XMLMotor.indexify splitd
|
13
14
|
go_nfo = {}
|
@@ -19,7 +20,6 @@ module Ci
|
|
19
20
|
go_nfo['weburls'] = XMLMotor.xmlattrib 'webUrl', splitd, tags, 'Project'
|
20
21
|
go_nfo
|
21
22
|
end
|
22
|
-
|
23
23
|
end
|
24
24
|
end
|
25
25
|
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
## print.rb
|
2
|
+
|
3
|
+
module Ci
|
4
|
+
module Go
|
5
|
+
module Print
|
6
|
+
|
7
|
+
def self.summary(passed_builds, failed_builds)
|
8
|
+
puts <<-OUTPUT
|
9
|
+
\e[1m\e[94mCI Summary\e[0m
|
10
|
+
Total \e[94mPipelines:\e[0m \e[94m#{passed_builds.size + failed_builds.size}\e[0m
|
11
|
+
Total \e[32mPassed\e[0m Pipelines: \e[94m#{passed_builds.size}\e[0m
|
12
|
+
Total \e[31mFailed\e[0m Pipelines: \e[94m#{failed_builds.size}\e[0m
|
13
|
+
\e[91mFailed\e[0m Build are:
|
14
|
+
OUTPUT
|
15
|
+
failed_builds.each do |build|
|
16
|
+
puts " \e[31m\e[1m#{build}\e[0m"
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
def self.build_status(build)
|
21
|
+
puts <<-OUTPUT
|
22
|
+
\e[1m\e[31m#{build['name'].gsub('::', '->')}
|
23
|
+
\e[32m#{build['last_status']} \e[0m for run#\e[32m#{build['last_label']} \e[33mat #{build['last_time']}
|
24
|
+
\e[0mdetails at \e[36m#{build['weburl']}
|
25
|
+
|
26
|
+
OUTPUT
|
27
|
+
end
|
28
|
+
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
data/lib/ci-go-nfo/version.rb
CHANGED
data/lib/ci-go-nfo/www.rb
CHANGED
@@ -1,4 +1,6 @@
|
|
1
1
|
## www.rb
|
2
|
+
# Ci::WWW.http ~ takes url and config{:user, :password}, gives http response
|
3
|
+
# Ci::WWW::Go.cctray_xml ~ return cctray.xml http response
|
2
4
|
|
3
5
|
require 'net/http'
|
4
6
|
require 'uri'
|
@@ -6,14 +8,25 @@ require 'uri'
|
|
6
8
|
module Ci
|
7
9
|
module WWW
|
8
10
|
|
9
|
-
def self.http
|
10
|
-
|
11
|
-
url = URI.parse("#{config['baseurl']}/go/cctray.xml")
|
11
|
+
def self.http(url, config)
|
12
|
+
url = URI.parse(url)
|
12
13
|
req = Net::HTTP::Get.new(url.path)
|
13
14
|
req.basic_auth(config['user'], config['password']) unless config['user'].nil?
|
14
|
-
Net::HTTP.start(url.host, url.port) {|http|
|
15
|
-
|
16
|
-
|
15
|
+
Net::HTTP.start(url.host, url.port) {|http| http.request(req) }
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
|
21
|
+
module Ci
|
22
|
+
module WWW
|
23
|
+
module Go
|
24
|
+
|
25
|
+
def self.cctray_xml
|
26
|
+
config = Ci::Go::Access.config
|
27
|
+
url = "#{config['baseurl']}/go/cctray.xml"
|
28
|
+
Ci::WWW.http url, config
|
29
|
+
end
|
17
30
|
end
|
18
31
|
end
|
19
32
|
end
|
data/resource/config.store
CHANGED
@@ -1 +1 @@
|
|
1
|
-
~/.go.
|
1
|
+
~/.ci.go.config
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ci-go-nfo
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-
|
12
|
+
date: 2012-10-28 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: xml-motor
|
@@ -54,15 +54,17 @@ extensions: []
|
|
54
54
|
extra_rdoc_files: []
|
55
55
|
files:
|
56
56
|
- .gitignore
|
57
|
+
- CHANGELOG
|
57
58
|
- Gemfile
|
58
59
|
- LICENSE
|
59
|
-
- README
|
60
|
+
- README
|
60
61
|
- Rakefile
|
61
62
|
- bin/ci-go-nfo
|
62
63
|
- ci-go-nfo.gemspec
|
63
64
|
- lib/ci-go-nfo.rb
|
64
65
|
- lib/ci-go-nfo/cctray.rb
|
65
66
|
- lib/ci-go-nfo/go_info.rb
|
67
|
+
- lib/ci-go-nfo/print.rb
|
66
68
|
- lib/ci-go-nfo/version.rb
|
67
69
|
- lib/ci-go-nfo/www.rb
|
68
70
|
- resource/config.store
|