jenkins-builder 0.1.1 → 0.1.2
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 +17 -7
- data/lib/jenkins/builder/app.rb +19 -0
- data/lib/jenkins/builder/cli.rb +7 -2
- data/lib/jenkins/builder/config.rb +8 -0
- data/lib/jenkins/builder/version.rb +1 -1
- 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: 6c813b09240b209488d82b385f69cb489ae98f76351d776e58b90d9e93eeb0ff
|
4
|
+
data.tar.gz: d9caa5b73d0b1c4659f380ae2ee396f92aca5e09cf6817ed3ab56b0e572627b0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bafb2136d76372bce62819f039ade1ee939d60cd802a82f9ca8228d50e109d2ede033835fcb309ac39a907d3a2d2cf631522e4ad2e45e658b070d9555045143b
|
7
|
+
data.tar.gz: 83fab1b1f53c99fdb8834d4677a66094bd122a22ff89b0322b19899d4ac24a8540c048242c33d50f2c18c41225c94f3a4980435a913d5ff3c87bd834be843750
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -4,12 +4,16 @@
|
|
4
4
|
|
5
5
|
## Requirements
|
6
6
|
|
7
|
-
1.
|
7
|
+
1. This gem uses macOS KeyChain for managing credentials for logging into jenkins website, so macOS is the only supported OS by now.
|
8
8
|
2. It use the `fzf` fuzzy selecting utility to filter jenkins job names and git branches, so before using this gem, you should install `fzf` first: `brew install fzf`.
|
9
9
|
|
10
10
|
## Installation
|
11
11
|
|
12
12
|
$ gem install jenkins-builder
|
13
|
+
|
14
|
+
If any permission errors occurs, prepend `sudo`:
|
15
|
+
|
16
|
+
$ sudo gem install jenkins-builder
|
13
17
|
|
14
18
|
## Usage
|
15
19
|
|
@@ -19,9 +23,9 @@
|
|
19
23
|
|
20
24
|
### Setup
|
21
25
|
|
22
|
-
All configuration
|
26
|
+
All configuration stores in `$HOME/.jenkins-builder.yaml` except password.
|
23
27
|
|
24
|
-
Password
|
28
|
+
Password stores in macOS KeyChain, KeyChain service name is `jenkins-builder-credentials`.
|
25
29
|
|
26
30
|
#### Setup URL and credentials interactively
|
27
31
|
|
@@ -31,7 +35,7 @@ Just run: `$ jk setup`
|
|
31
35
|
|
32
36
|
$ jk info
|
33
37
|
|
34
|
-
By default,
|
38
|
+
By default, password will not be shown, but if you want: `$ jk info -p`
|
35
39
|
|
36
40
|
#### Edit config file directly
|
37
41
|
|
@@ -42,6 +46,12 @@ By default, it does now show password, but if you want it: `$ jk info -p`
|
|
42
46
|
#### Specify job identifiers as command line arguments
|
43
47
|
|
44
48
|
$ jk build project1 project2 ...
|
49
|
+
|
50
|
+
#### Fail-Fast
|
51
|
+
|
52
|
+
If multiple jobs are specified, all jobs will be built by default. If yout wanna cancel all subsequent jobs after some job failed, use `-f` option of `build` command:
|
53
|
+
|
54
|
+
# jk build -f project1 project2 ...
|
45
55
|
|
46
56
|
#### Specify git brand if you use mbranch plugin
|
47
57
|
|
@@ -57,17 +67,17 @@ Just run `jk build` without job identifiers specified as command line arguments:
|
|
57
67
|
|
58
68
|
$ jk build
|
59
69
|
|
60
|
-
|
70
|
+
Or even just (because `build` is the default task):
|
61
71
|
|
62
72
|
$ jk
|
63
73
|
|
64
74
|
### Alias
|
65
75
|
|
66
|
-
For most
|
76
|
+
For most common used jobs, you can create aliases for them for convenience.
|
67
77
|
|
68
78
|
#### Create an alias
|
69
79
|
|
70
|
-
$ jk alias p1 project1:origin/develop
|
80
|
+
$ jk alias p1 'build project1:origin/develop'
|
71
81
|
|
72
82
|
then you could just run:
|
73
83
|
|
data/lib/jenkins/builder/app.rb
CHANGED
@@ -4,6 +4,7 @@ require 'jenkins/builder/secret'
|
|
4
4
|
require 'jenkins_api_client'
|
5
5
|
require 'pastel'
|
6
6
|
require 'tty-spinner'
|
7
|
+
require 'time'
|
7
8
|
|
8
9
|
module Jenkins
|
9
10
|
module Builder
|
@@ -92,6 +93,24 @@ module Jenkins
|
|
92
93
|
check_and_show_result(job_name, latest_build_no)
|
93
94
|
end
|
94
95
|
|
96
|
+
def fetch_all_jobs
|
97
|
+
refresh_jobs_cache unless validate_jobs_cache
|
98
|
+
@config['jobs-cache']['jobs']
|
99
|
+
end
|
100
|
+
|
101
|
+
def refresh_jobs_cache
|
102
|
+
@config['jobs-cache'] = {
|
103
|
+
'expire' => (Time.now + 86400*30).strftime('%F %T'),
|
104
|
+
'jobs' => all_jobs
|
105
|
+
}
|
106
|
+
@config.save!
|
107
|
+
end
|
108
|
+
|
109
|
+
def validate_jobs_cache
|
110
|
+
@config['jobs-cache'] && !@config['jobs-cache'].empty? && \
|
111
|
+
Time.parse(@config['jobs-cache']['expire']) > Time.now
|
112
|
+
end
|
113
|
+
|
95
114
|
def all_jobs
|
96
115
|
@client.job.list_all
|
97
116
|
end
|
data/lib/jenkins/builder/cli.rb
CHANGED
@@ -9,7 +9,7 @@ module Jenkins
|
|
9
9
|
class << self
|
10
10
|
def create_alias_commands(aliases)
|
11
11
|
aliases.each do |name, command|
|
12
|
-
desc "#{name}", "
|
12
|
+
desc "#{name}", "Alias for: `#{command}'"
|
13
13
|
define_method name do |*args|
|
14
14
|
self.class.start(Shellwords.split(command) + args)
|
15
15
|
end
|
@@ -45,7 +45,7 @@ module Jenkins
|
|
45
45
|
def build(*jobs)
|
46
46
|
app = Jenkins::Builder::App.new(options)
|
47
47
|
if jobs.empty?
|
48
|
-
jobs = fzf(app.
|
48
|
+
jobs = fzf(app.fetch_all_jobs)
|
49
49
|
exit if jobs.empty?
|
50
50
|
job = jobs.first
|
51
51
|
|
@@ -76,6 +76,11 @@ module Jenkins
|
|
76
76
|
Jenkins::Builder::App.new.delete_alias(name)
|
77
77
|
end
|
78
78
|
|
79
|
+
desc 'refresh-jobs-cache', 'Refresh cache of job names'
|
80
|
+
def refresh_jobs_cache
|
81
|
+
Jenkins::Builder::App.new.refresh_jobs_cache
|
82
|
+
end
|
83
|
+
|
79
84
|
default_task :build
|
80
85
|
|
81
86
|
no_commands do
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jenkins-builder
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Liu Xiang
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-11-
|
11
|
+
date: 2018-11-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: thor
|