bard 0.25.1 → 0.25.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/bard/ci.rb +30 -13
- data/lib/bard/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a93db2ad80e6104a194831ff80a71668b59f492d
|
4
|
+
data.tar.gz: b97f43d932e49a5d10789e7ac5bcd14401745ce7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3a14f2fd1b3bc0b27e2b1dd7d2d11396c191613064f0285164728d7c07c821af5f1baa031259e9de318241ef42b90e8e76f2a198be60fc2d0dcd40e1f2962c49
|
7
|
+
data.tar.gz: 1cb87e22fb668b40b9a4ae3f56712afebac411871976921599cb03da5b8d3e595fba7a148f041a7121856c56abed414382b65841c500af81a4c567c6c186d871
|
data/lib/bard/ci.rb
CHANGED
@@ -1,19 +1,18 @@
|
|
1
1
|
class Bard::CLI < Thor
|
2
2
|
class CI < Struct.new(:project_name, :current_sha)
|
3
3
|
def run
|
4
|
-
last_build_number = get_last_build_number
|
5
4
|
last_time_elapsed = get_last_time_elapsed
|
6
5
|
start
|
7
|
-
sleep(2)
|
6
|
+
sleep(2) until started?
|
8
7
|
|
9
8
|
start_time = Time.new.to_i
|
10
|
-
while
|
9
|
+
while building?
|
11
10
|
elapsed_time = Time.new.to_i - start_time
|
12
11
|
yield elapsed_time, last_time_elapsed
|
13
12
|
sleep(2)
|
14
13
|
end
|
15
14
|
|
16
|
-
|
15
|
+
success?
|
17
16
|
end
|
18
17
|
|
19
18
|
def exists?
|
@@ -29,24 +28,42 @@ class Bard::CLI < Thor
|
|
29
28
|
|
30
29
|
private
|
31
30
|
|
31
|
+
def get_last_time_elapsed
|
32
|
+
response = `curl -s #{ci_host}/lastStableBuild/api/xml?token=botandrose`
|
33
|
+
response.match(/<duration>(\d+)<\/duration>/)
|
34
|
+
$1 ? $1.to_i / 1000 : nil
|
35
|
+
end
|
36
|
+
|
32
37
|
def ci_host
|
33
38
|
"http://botandrose:thecakeisalie!@ci.botandrose.com/job/#{project_name}"
|
34
39
|
end
|
35
40
|
|
36
41
|
def start
|
37
|
-
|
42
|
+
command = "curl -s -I -X POST '#{ci_host}/buildWithParameters?token=botandrose&GIT_REF=#{current_sha}'"
|
43
|
+
output = `#{command}`
|
44
|
+
@queueId = output[%r{Location: .+/queue/item/(\d+)/}, 1].to_i
|
38
45
|
end
|
39
46
|
|
40
|
-
def
|
41
|
-
|
42
|
-
|
43
|
-
|
47
|
+
def started?
|
48
|
+
command = "curl -s -g '#{ci_host}/api/json?depth=1&tree=builds[queueId,number]'"
|
49
|
+
output = `#{command}`
|
50
|
+
output =~ /"queueId":#{@queueId}\b/
|
44
51
|
end
|
45
52
|
|
46
|
-
def
|
47
|
-
|
48
|
-
|
49
|
-
|
53
|
+
def job_id
|
54
|
+
@job_id ||= begin
|
55
|
+
output = `curl -s -g '#{ci_host}/api/json?depth=1&tree=builds[queueId,number]'`
|
56
|
+
output[/"number":(\d+),"queueId":#{@queueId}\b/, 1].to_i
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
def building?
|
61
|
+
self.last_response = `curl -s #{ci_host}/#{job_id}/api/json?tree=building,result`
|
62
|
+
last_response.include? '"building":true'
|
63
|
+
end
|
64
|
+
|
65
|
+
def success?
|
66
|
+
last_response.include? '"result":"SUCCESS"'
|
50
67
|
end
|
51
68
|
end
|
52
69
|
end
|
data/lib/bard/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bard
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.25.
|
4
|
+
version: 0.25.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Micah Geisel
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2016-03-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: thor
|