circleci-cli 2.0.0 → 2.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/README.md +35 -2
- data/lib/circleci/cli.rb +2 -0
- data/lib/circleci/cli/command/build_command.rb +18 -2
- data/lib/circleci/cli/command/retry_command.rb +18 -2
- data/lib/circleci/cli/command/watch_command.rb +1 -1
- data/lib/circleci/cli/command/watch_command/build_watcher.rb +3 -3
- data/lib/circleci/cli/printer/build_printer.rb +5 -5
- data/lib/circleci/cli/response/build.rb +6 -0
- data/lib/circleci/cli/version.rb +1 -1
- data/movie/rec.gif +0 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0a4d26f78c55597cf3becbb35a01830eeff0bea849595d9a598cee83ff005380
|
4
|
+
data.tar.gz: 12f4072a51aaf0841a029d4cdda58ecdd7248f71d768a7fe9ddbd08e43ad532f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d88223bc635c85aacbb66d2a3e8a5460d8596f3e5e04abdacb283f0da02bcc51bdd82c115b560f478a16f05632da1390b2b99534d1e316292d2ed0c2fb987510
|
7
|
+
data.tar.gz: 79ffab76da11996aed822d93ce98cfad09b09e3424b837465409c937b7e334ac9a94d99071a0542c7d505ca267c1943b793e96680f2612faee19d6b6291d676a
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -1,5 +1,7 @@
|
|
1
1
|
# circleci-cli
|
2
2
|
|
3
|
+
Notice: This gem is renamed from `circler` to `circleci-cli` on 2019/09/22
|
4
|
+
|
3
5
|
[![Gem Version](https://badge.fury.io/rb/circleci-cli.svg)](https://badge.fury.io/rb/circleci-cli)
|
4
6
|
[![Circle CI](https://circleci.com/gh/unhappychoice/circleci-cli.svg?style=shield)](https://circleci.com/gh/unhappychoice/circleci-cli)
|
5
7
|
[![Code Climate](https://codeclimate.com/github/unhappychoice/circleci-cli/badges/gpa.svg)](https://codeclimate.com/github/unhappychoice/circleci-cli)
|
@@ -12,8 +14,6 @@ circleci-cli is a CLI tool for [Circle CI](https://circleci.com).
|
|
12
14
|
|
13
15
|
![sample.gif](https://github.com/unhappychoice/circler/raw/master/movie/rec.gif)
|
14
16
|
|
15
|
-
Notice: This gem is renamed from `circler` to `circleci-cli` on 2019/09/22
|
16
|
-
|
17
17
|
## Installation
|
18
18
|
|
19
19
|
```sh
|
@@ -42,6 +42,39 @@ Options:
|
|
42
42
|
-p user_name/project # specify repository
|
43
43
|
-b branch # specify branch name
|
44
44
|
-n build_number # specify build number
|
45
|
+
-l last # get or retry last failed build
|
46
|
+
-v verbose # show all the logs if applied to watch command
|
47
|
+
```
|
48
|
+
|
49
|
+
### Project argument
|
50
|
+
|
51
|
+
Project argument will be automatically selected in your directory initialized with git.
|
52
|
+
|
53
|
+
### Examples
|
54
|
+
|
55
|
+
#### Watch your project
|
56
|
+
```
|
57
|
+
$ circleci-cli watch
|
58
|
+
```
|
59
|
+
|
60
|
+
#### Watch your project and show all of the build log
|
61
|
+
```
|
62
|
+
$ circleci-cli watch -v
|
63
|
+
```
|
64
|
+
|
65
|
+
#### Show last failed build
|
66
|
+
```
|
67
|
+
$ circleci-cli build --last
|
68
|
+
```
|
69
|
+
|
70
|
+
#### Retry last failed build
|
71
|
+
```
|
72
|
+
$ circleci-cli retry --last
|
73
|
+
```
|
74
|
+
|
75
|
+
#### Open CircleCI webpage for current project
|
76
|
+
```
|
77
|
+
$ circleci-cli browse
|
45
78
|
```
|
46
79
|
|
47
80
|
## Contributing
|
data/lib/circleci/cli.rb
CHANGED
@@ -36,6 +36,7 @@ module CircleCI
|
|
36
36
|
desc 'build', 'show build description'
|
37
37
|
method_option :project, aliases: 'p', type: :string, banner: 'user/project'
|
38
38
|
method_option :build, aliases: 'n', type: :numeric, banner: 'build-number'
|
39
|
+
method_option :last, aliases: 'l', type: :boolean, banner: 'get last failed build'
|
39
40
|
def build
|
40
41
|
Command::BuildCommand.run(options)
|
41
42
|
end
|
@@ -50,6 +51,7 @@ module CircleCI
|
|
50
51
|
desc 'retry', 'retry a build'
|
51
52
|
method_option :project, aliases: 'p', type: :string, banner: 'user/project'
|
52
53
|
method_option :build, aliases: 'n', type: :numeric, banner: 'build-number'
|
54
|
+
method_option :last, aliases: 'l', type: :boolean, banner: 'retry last failed build'
|
53
55
|
def retry
|
54
56
|
Command::RetryCommand.run(options)
|
55
57
|
end
|
@@ -8,10 +8,26 @@ module CircleCI
|
|
8
8
|
def run(options)
|
9
9
|
setup_token
|
10
10
|
username, reponame = project_name(options).split('/')
|
11
|
-
|
12
|
-
|
11
|
+
build =
|
12
|
+
if options.last
|
13
|
+
get_last_build(username, reponame)
|
14
|
+
else
|
15
|
+
get_build(username, reponame, options)
|
16
|
+
end
|
13
17
|
say Printer::StepPrinter.new(build.steps).to_s
|
14
18
|
end
|
19
|
+
|
20
|
+
private
|
21
|
+
|
22
|
+
def get_build(username, reponame, options)
|
23
|
+
number = build_number(options)
|
24
|
+
Response::Build.get(username, reponame, number)
|
25
|
+
end
|
26
|
+
|
27
|
+
def get_last_build(username, reponame)
|
28
|
+
builds = Response::Build.failed(username, reponame)
|
29
|
+
Response::Build.get(username, reponame, builds.map(&:build_number).max)
|
30
|
+
end
|
15
31
|
end
|
16
32
|
end
|
17
33
|
end
|
@@ -8,14 +8,30 @@ module CircleCI
|
|
8
8
|
def run(options)
|
9
9
|
setup_token
|
10
10
|
username, reponame = project_name(options).split('/')
|
11
|
-
number =
|
11
|
+
number = build_number_for(username, reponame, options)
|
12
|
+
|
12
13
|
build = Response::Build.retry(username, reponame, number)
|
13
|
-
|
14
|
+
|
15
|
+
if build&.username
|
14
16
|
say "build #{username}/#{reponame} #{build.build_number} is triggered"
|
15
17
|
else
|
16
18
|
say "failed to trigger #{username}/#{reponame} #{number}"
|
17
19
|
end
|
18
20
|
end
|
21
|
+
|
22
|
+
private
|
23
|
+
|
24
|
+
def build_number_for(username, reponame, options)
|
25
|
+
if options.last
|
26
|
+
get_last_build_number(username, reponame)
|
27
|
+
else
|
28
|
+
build_number(options)
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
def get_last_build_number(username, reponame)
|
33
|
+
Response::Build.failed(username, reponame).map(&:build_number).max
|
34
|
+
end
|
19
35
|
end
|
20
36
|
end
|
21
37
|
end
|
@@ -57,7 +57,7 @@ module CircleCI
|
|
57
57
|
def show_interrupted_build_results # rubocop:disable Metrics/AbcSize
|
58
58
|
@repository.builds_to_show.select(&:finished?).each do |build|
|
59
59
|
b = Response::Build.get(build.username, build.reponame, build.build_number)
|
60
|
-
title = "✅ Result of #{build.project_name} ##{build.build_number} completed in background"
|
60
|
+
title = "✅ Result of #{build.project_name} ##{build.build_number} completed in background"
|
61
61
|
say Printer::BuildPrinter.header_for(build, title)
|
62
62
|
say Printer::StepPrinter.new(b.steps, pretty: @options.verbose).to_s
|
63
63
|
@repository.mark_as_shown(b.build_number)
|
@@ -28,9 +28,9 @@ module CircleCI
|
|
28
28
|
def bind_event_handling(channel) # rubocop:disable Metrics/AbcSize, Metrics/MethodLength
|
29
29
|
@client.bind_event_json(channel, 'newAction') do |json|
|
30
30
|
if @verbose
|
31
|
-
print_bordered json['log']['name']
|
31
|
+
print_bordered json['log']['name']
|
32
32
|
else
|
33
|
-
print json['log']['name']
|
33
|
+
print json['log']['name']
|
34
34
|
end
|
35
35
|
end
|
36
36
|
|
@@ -56,7 +56,7 @@ module CircleCI
|
|
56
56
|
end
|
57
57
|
|
58
58
|
def notify_started
|
59
|
-
title = "👀 Start watching #{@build.project_name} ##{@build.build_number}"
|
59
|
+
title = "👀 Start watching #{@build.project_name} ##{@build.build_number}"
|
60
60
|
say Printer::BuildPrinter.header_for(@build, title)
|
61
61
|
end
|
62
62
|
|
@@ -5,12 +5,12 @@ module CircleCI
|
|
5
5
|
module Printer
|
6
6
|
class BuildPrinter
|
7
7
|
class << self
|
8
|
-
def header_for(build, title)
|
8
|
+
def header_for(build, title)
|
9
9
|
texts = [
|
10
|
-
['Project: '
|
11
|
-
['Build: '
|
12
|
-
['Author: '
|
13
|
-
['Workflow: '
|
10
|
+
['Project: ' + build.project_name],
|
11
|
+
['Build: ' + build.build_number.to_s],
|
12
|
+
['Author: ' + build.author_name],
|
13
|
+
['Workflow: ' + "#{build.workflow_name}/#{build.workflow_job_name}"]
|
14
14
|
]
|
15
15
|
Terminal::Table.new(title: title, rows: texts, style: { width: 120 }).to_s
|
16
16
|
end
|
@@ -11,6 +11,12 @@ module CircleCI
|
|
11
11
|
.map { |b| Build.new(b) }
|
12
12
|
end
|
13
13
|
|
14
|
+
def failed(username, reponame)
|
15
|
+
CircleCi::Project.new(username, reponame, 'github').recent_builds(filter: 'failed')
|
16
|
+
.body
|
17
|
+
.map { |b| Build.new(b) }
|
18
|
+
end
|
19
|
+
|
14
20
|
def branch(username, reponame, branch)
|
15
21
|
CircleCi::Project.new(username, reponame, 'github').recent_builds_branch(branch)
|
16
22
|
.body
|
data/lib/circleci/cli/version.rb
CHANGED
data/movie/rec.gif
CHANGED
Binary file
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: circleci-cli
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- unhappychoice
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-09-
|
11
|
+
date: 2019-09-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: circleci
|