jenkins-builder 0.2.4 → 0.2.5

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: d859f94d866333f40f01c75294f3a661aa3405d3dd5708413a41d541c492fd3d
4
- data.tar.gz: e07d8c00473081eade301747df108a8f0a25b06136a49391328741459f4c6a0c
3
+ metadata.gz: b3d8b25fd6d3fd82e3fb04b58038f3d536d907510def01ae42ecb6d09ad8bb9b
4
+ data.tar.gz: 9e623633692b17797b3ac2fc3ee425f7b6da70ca1e7ae9acd119d00cfb2e34ce
5
5
  SHA512:
6
- metadata.gz: 42578f536ef60c4a738367fae25116eb64b6c82ec1c968914be3f31a4c1560279ffd66120d2573a4531ba553a27a34c2bc95f021814053bd57ede7f68726aa9b
7
- data.tar.gz: 4f691e4dcc7cea39bdd455166b01437004ec59c96c0e38a4ee30828e16cea5b20cc074ea6262380cc20ef7d13249366d637bf8d1d337bd846532bfb65261bfe4
6
+ metadata.gz: 562efc35d87d9e2e3786ee18f994e2445c5927d9349da8c47edbe53a902010345756e2b986d98e03ed287fbdb8b9a6dafe77292ee3fb2b6dce17c0785876db1a
7
+ data.tar.gz: 17350f8058207c60c647767ac91392777a756111cf401b6d9ad4ab8e91fc02374771c469c05057e18cdc3eea47ff6a52f82971ee97fe484fc68cf88baccd6eae
@@ -1,7 +1,8 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- jenkins-builder (0.2.3)
4
+ jenkins-builder (0.2.5)
5
+ ferrum (~> 0.9)
5
6
  jenkins_api_client (~> 1.5.3)
6
7
  pastel (~> 0.7.2)
7
8
  security (~> 0.1.3)
@@ -11,10 +12,20 @@ PATH
11
12
  GEM
12
13
  remote: https://gems.ruby-china.com/
13
14
  specs:
15
+ addressable (2.7.0)
16
+ public_suffix (>= 2.0.2, < 5.0)
14
17
  byebug (10.0.2)
18
+ chef-utils (16.3.38)
19
+ cliver (0.3.2)
15
20
  coderay (1.1.2)
21
+ concurrent-ruby (1.1.6)
16
22
  diff-lcs (1.3)
17
- equatable (0.5.0)
23
+ equatable (0.6.1)
24
+ ferrum (0.9)
25
+ addressable (~> 2.5)
26
+ cliver (~> 0.3)
27
+ concurrent-ruby (~> 1.1)
28
+ websocket-driver (>= 0.6, < 0.8)
18
29
  jenkins_api_client (1.5.3)
19
30
  json (>= 1.0)
20
31
  mixlib-shellout (>= 1.1.0)
@@ -22,15 +33,16 @@ GEM
22
33
  socksify (>= 1.7.0)
23
34
  terminal-table (>= 1.4.0)
24
35
  thor (>= 0.16.0)
25
- json (2.3.0)
36
+ json (2.3.1)
26
37
  method_source (0.9.1)
27
38
  mini_portile2 (2.4.0)
28
- mixlib-shellout (2.4.0)
29
- nokogiri (1.10.9)
39
+ mixlib-shellout (3.1.2)
40
+ chef-utils
41
+ nokogiri (1.10.10)
30
42
  mini_portile2 (~> 2.4.0)
31
- pastel (0.7.2)
32
- equatable (~> 0.5.0)
33
- tty-color (~> 0.4.0)
43
+ pastel (0.7.4)
44
+ equatable (~> 0.6)
45
+ tty-color (~> 0.5)
34
46
  pry (0.11.3)
35
47
  coderay (~> 1.1.0)
36
48
  method_source (~> 0.9.0)
@@ -40,6 +52,7 @@ GEM
40
52
  pry-doc (0.13.4)
41
53
  pry (~> 0.11)
42
54
  yard (~> 0.9.11)
55
+ public_suffix (4.0.5)
43
56
  rake (10.5.0)
44
57
  rspec (3.8.0)
45
58
  rspec-core (~> 3.8.0)
@@ -59,11 +72,14 @@ GEM
59
72
  terminal-table (1.8.0)
60
73
  unicode-display_width (~> 1.1, >= 1.1.1)
61
74
  thor (0.20.3)
62
- tty-color (0.4.3)
63
- tty-cursor (0.6.0)
75
+ tty-color (0.5.1)
76
+ tty-cursor (0.7.1)
64
77
  tty-spinner (0.8.0)
65
78
  tty-cursor (>= 0.5.0)
66
79
  unicode-display_width (1.7.0)
80
+ websocket-driver (0.7.3)
81
+ websocket-extensions (>= 0.1.0)
82
+ websocket-extensions (0.1.5)
67
83
  yard (0.9.24)
68
84
 
69
85
  PLATFORMS
@@ -35,6 +35,7 @@ Gem::Specification.new do |spec|
35
35
  spec.add_dependency 'security', '~> 0.1.3'
36
36
  spec.add_dependency 'pastel', '~> 0.7.2'
37
37
  spec.add_dependency 'tty-spinner', '~> 0.8.0'
38
+ spec.add_dependency 'ferrum', '~> 0.9'
38
39
 
39
40
  spec.add_development_dependency "bundler", "~> 2.1.2"
40
41
  spec.add_development_dependency "rake", "~> 10.0"
@@ -5,6 +5,7 @@ require 'pastel'
5
5
  require 'tty-spinner'
6
6
  require 'time'
7
7
  require 'cgi'
8
+ require 'ferrum'
8
9
 
9
10
 
10
11
  module JenkinsApi
@@ -147,14 +148,42 @@ module Jenkins
147
148
  msg = "#{job_name} with branch #{branch}"
148
149
  mbranch_param = {name: 'mbranch', value: branch}
149
150
  params = mbranch_param.merge(json: {parameter: mbranch_param}.to_json)
150
- @client.api_post_request("/job/#{job_name}/build?delay=0sec", params, true)
151
+ begin
152
+ @client.api_post_request("/job/#{job_name}/build?delay=0sec", params, true)
153
+ rescue JenkinsApi::Exceptions::ForbiddenWithCrumb => e
154
+ start_build_use_ferrum(job_name, branch)
155
+ end
151
156
  else
152
157
  msg = job_name
153
- @client.api_post_request("/job/#{job_name}/build?delay=0sec")
158
+ begin
159
+ @client.api_post_request("/job/#{job_name}/build?delay=0sec")
160
+ rescue JenkinsApi::Exceptions::ForbiddenWithCrumb => e
161
+ start_build_use_ferrum(job_name, nil)
162
+ end
154
163
  end
155
164
  puts Pastel.new.cyan.bold("\n%s%s %s %s%s\n" % [' '*30, '★ '*5, msg, '★ '*5, ' '*30])
156
165
  end
157
166
 
167
+ def start_build_use_ferrum(job_name, branch)
168
+ browser = Ferrum::Browser.new(headless: false)
169
+ browser.goto("#{config.url}/login")
170
+ username_input = browser.at_css('input[name=j_username]')
171
+ password_input = browser.at_css('input[name=j_password]')
172
+ username_input.focus.type(config.username)
173
+ password_input.focus.type(config.password)
174
+ browser.at_css('input[name=Submit]').click
175
+ if branch
176
+ browser.goto("#{config.url}/job/#{job_name}/build?delay=0sec")
177
+ sleep(2)
178
+ browser.evaluate("document.querySelector('#gitParameterSelect').value = '#{branch}'")
179
+ browser.at_css('#yui-gen1-button').click
180
+ else
181
+ browser.goto("#{config.url}/job/#{job_name}/")
182
+ browser.at_xpath('#tasks a.task-link').click
183
+ end
184
+ browser.quit
185
+ end
186
+
158
187
  def check_and_show_result(job_name, latest_build_no)
159
188
  while (build_no = @client.job.get_current_build_number(job_name)) <= latest_build_no
160
189
  sleep 1
@@ -1,5 +1,5 @@
1
1
  module Jenkins
2
2
  module Builder
3
- VERSION = "0.2.4"
3
+ VERSION = "0.2.5"
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.2.4
4
+ version: 0.2.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Liu Xiang
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-07-10 00:00:00.000000000 Z
11
+ date: 2020-07-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: thor
@@ -80,6 +80,20 @@ dependencies:
80
80
  - - "~>"
81
81
  - !ruby/object:Gem::Version
82
82
  version: 0.8.0
83
+ - !ruby/object:Gem::Dependency
84
+ name: ferrum
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: '0.9'
90
+ type: :runtime
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: '0.9'
83
97
  - !ruby/object:Gem::Dependency
84
98
  name: bundler
85
99
  requirement: !ruby/object:Gem::Requirement