jenkins-builder 0.1.3 → 0.1.4

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: 6264808c55756429aa6b019ead0837cb0b06543deefe5ec277f7ec87406fd9e8
4
- data.tar.gz: 7ddb8c0aa2ef3a789ab9e98a2ff4d9b39f6fcd8ebeeec1f02a3530000bd80cbc
3
+ metadata.gz: aa73cdb92828d5e151cc9a8b78c72a8541383c86600576b9d706247413c7dc4c
4
+ data.tar.gz: 16ff0f621a460a3866cc1d5ed79b485ac694877400bdfa5a0a80b0498cd8db05
5
5
  SHA512:
6
- metadata.gz: d795984618ab30bd9bfef3c47c3f365a2d7c7c322a5fadb7503fd09580c33e0eca423d9a536d14e34abecdb4c8cdfb004c2ac037ec054b03d49032ab67e61b0d
7
- data.tar.gz: 2b482ec4adc11376de1f633fd3d6d356d82c2fca2733e2cb2b90903e9f664728f51630aec5b8c474119b17dadceef4468b83eda499add8f5d5247eed2be66c08
6
+ metadata.gz: 57b091506ea5e682173a4246c876b06d810c29f26ab89756c01a9ad26593d034cce4d7850b114bcad3fa8f5154e70485aa14a40d57f9169ea427d0af155449cc
7
+ data.tar.gz: f33aedd9b5e1b8755f6a9e02db5b50ce06cc24a43cd1d9870816fe7812ef01b866e7db1915f4a33ec592948b9a4fa9989b9c01f2e1780475471d98f590326242
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- jenkins-builder (0.1.3)
4
+ jenkins-builder (0.1.4)
5
5
  jenkins_api_client (~> 1.5.3)
6
6
  pastel (~> 0.7.2)
7
7
  security (~> 0.1.3)
data/README.md CHANGED
@@ -92,6 +92,36 @@ it's equivalent to run `jk build project1:origin/develop`
92
92
  #### Delete an alias
93
93
 
94
94
  $ jk unalias p1
95
+
96
+ ### Hooks
97
+
98
+ You can add hooks into configuration, which will be executed after a job build finished, the console output will be sent to the hook process as STDIN. See Config Example.
99
+
100
+
101
+ ### Config Example
102
+
103
+ ```
104
+ ---
105
+ url: http://jenkins.example.com
106
+ username: lululau
107
+ branches:
108
+ - origin/develop
109
+ - origin/staging
110
+ - origin/master
111
+ aliases:
112
+ kd: build kubernetes:origin/develop
113
+ km: build kubernetes:origin/master
114
+ lc: build linux_core
115
+ hooks:
116
+ linux_core: "ssh my_server 'cd /var/logs/ && tail -f $(ls -t | head -1)'"
117
+ kubernetes: "/my/local/machine/clean.sh"
118
+ jobs-cache:
119
+ expire: '2018-12-16 11:25:11'
120
+ jobs:
121
+ - kubernetes
122
+ - linux_core
123
+ - my_e_shop
124
+ ```
95
125
 
96
126
  ## Development
97
127
 
@@ -149,8 +149,12 @@ module Jenkins
149
149
  spinner = TTY::Spinner.new(':spinner Building ...', format: :bouncing_ball)
150
150
  spinner.auto_spin
151
151
  end
152
+
153
+ all_console_output = ''
154
+
152
155
  loop do
153
156
  console_output = @client.job.get_console_output(job_name, build_no, printed_size, 'text')
157
+ all_console_output << console_output['output']
154
158
  print console_output['output'].gsub("\r", '') unless @options[:silent]
155
159
  printed_size += console_output['size'].to_i
156
160
  break unless console_output['more']
@@ -168,6 +172,21 @@ module Jenkins
168
172
  puts pastel.red.bold(msg)
169
173
  end
170
174
 
175
+ if hooks = @config.hooks_of(job_name)
176
+ hooks.each do |hook|
177
+ puts pastel.green('Execute hook: "%s"' % hook)
178
+ begin
179
+ IO.popen(hook, 'r+') do |process|
180
+ process.print(all_console_output)
181
+ process.each { |line| print line }
182
+ end
183
+ rescue Interrupt
184
+ puts
185
+ puts pastel.red('User Canceld hook: "%s"' % hook)
186
+ end
187
+ end
188
+ end
189
+
171
190
  msg =~ /SUCCESS/
172
191
  end
173
192
 
@@ -57,6 +57,12 @@ module Jenkins
57
57
  @config['branches'] = branches
58
58
  end
59
59
 
60
+ def hooks_of(job)
61
+ hooks = @config['hooks'] && @config['hooks'][job]
62
+ hooks = [hooks] if hooks.is_a?(String)
63
+ hooks
64
+ end
65
+
60
66
  def init
61
67
  @config = {}
62
68
  save(@config, @file)
@@ -1,5 +1,5 @@
1
1
  module Jenkins
2
2
  module Builder
3
- VERSION = "0.1.3"
3
+ VERSION = "0.1.4"
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.3
4
+ version: 0.1.4
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-16 00:00:00.000000000 Z
11
+ date: 2018-11-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: thor