-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcircleci
More file actions
executable file
·42 lines (36 loc) · 971 Bytes
/
circleci
File metadata and controls
executable file
·42 lines (36 loc) · 971 Bytes
1
2
3
4
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
32
33
34
35
36
37
38
39
40
41
42
#!/usr/bin/env ruby
# by tlehman
# CircleCI recent builds
# depends on colorize gem
require 'json'
require 'colorize'
COLOR = {'success' => :green,
'fixed' => :green,
'failed' => :red,
'not_run' => :white,
'no_tests' => :red}
def missing_env?
ENV["CIRCLECI_TOKEN"].nil?
end
def recent_builds_json
`curl -s -H "Accept: application/json" "https://circleci.com/api/v1/recent-builds?circle-token=$CIRCLECI_TOKEN"`
end
def format_build(build)
color = COLOR[build['status']] || 'white'
"".tap do |line|
line << build['reponame'].ljust(20, " ")
line << build['lifecycle'].ljust(15, " ")
line << build['status'].ljust(15, " ")
line << build['author_name'].to_s.ljust(30, " ")
end.send(color)
end
def recent_builds
if missing_env?
puts "Missing CIRCLECI_TOKEN environment variable"
return
end
JSON.parse(recent_builds_json).each do |build|
puts format_build(build)
end
end
recent_builds