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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b39898848784b84c87559eb63675f51dc4a03823ee35fe2da7dd749edd5d621c
4
- data.tar.gz: 39212caecea142e17c80df6d37f94d4494bb30d0694059a983b17e50939c6181
3
+ metadata.gz: 6c813b09240b209488d82b385f69cb489ae98f76351d776e58b90d9e93eeb0ff
4
+ data.tar.gz: d9caa5b73d0b1c4659f380ae2ee396f92aca5e09cf6817ed3ab56b0e572627b0
5
5
  SHA512:
6
- metadata.gz: 8cd027c6c46a93b6478e2fa9aed14f5032843a4d9661ed86ee9332c11acf6ad1af083a0aed72ac52c271989213a3fc14820a9f093f02740554a656e83e0cfc36
7
- data.tar.gz: c8edb12b96dfdf9ec8e74e445632175c75316bb98113d4b0a74bbb4078d1fa30f6a663a92ff0b56bfec6d1d481009747c8875a28f72c3c41e92202323c221706
6
+ metadata.gz: bafb2136d76372bce62819f039ade1ee939d60cd802a82f9ca8228d50e109d2ede033835fcb309ac39a907d3a2d2cf631522e4ad2e45e658b070d9555045143b
7
+ data.tar.gz: 83fab1b1f53c99fdb8834d4677a66094bd122a22ff89b0322b19899d4ac24a8540c048242c33d50f2c18c41225c94f3a4980435a913d5ff3c87bd834be843750
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- jenkins-builder (0.1.1)
4
+ jenkins-builder (0.1.2)
5
5
  jenkins_api_client (~> 1.5.3)
6
6
  pastel (~> 0.7.2)
7
7
  security (~> 0.1.3)
data/README.md CHANGED
@@ -4,12 +4,16 @@
4
4
 
5
5
  ## Requirements
6
6
 
7
- 1. The gem use macOS KeyChain for managing credentials for logging into jenkins website, so macOS is the only supported OS by now.
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 is stored in `$HOME/.jenkins-builder.yaml` except password.
26
+ All configuration stores in `$HOME/.jenkins-builder.yaml` except password.
23
27
 
24
- Password is stored in macOS KeyChain, its service name is `jenkins-builder-credentials`.
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, it does now show password, but if you want it: `$ jk info -p`
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
- Even just (because `build` is the default task):
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 working jobs, you can create aliases for them for convenice.
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
 
@@ -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
@@ -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}", "alias for: #{command}"
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.all_jobs)
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
@@ -17,6 +17,14 @@ module Jenkins
17
17
  end
18
18
  end
19
19
 
20
+ def [](k)
21
+ @config[k]
22
+ end
23
+
24
+ def []=(k, v)
25
+ @config[k] = v
26
+ end
27
+
20
28
  def username
21
29
  @config['username']
22
30
  end
@@ -1,5 +1,5 @@
1
1
  module Jenkins
2
2
  module Builder
3
- VERSION = "0.1.1"
3
+ VERSION = "0.1.2"
4
4
  end
5
5
  end
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.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-06 00:00:00.000000000 Z
11
+ date: 2018-11-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: thor