jenkins_api_client 0.14.1 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (40) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +3 -0
  3. data/.travis.yml +5 -23
  4. data/CHANGELOG.md +104 -35
  5. data/CONTRIBUTORS.md +1 -11
  6. data/Gemfile +4 -2
  7. data/README.md +107 -7
  8. data/Rakefile +1 -0
  9. data/Vagrantfile +6 -8
  10. data/jenkins_api_client.gemspec +30 -12
  11. data/lib/jenkins_api_client/cli/helper.rb +1 -0
  12. data/lib/jenkins_api_client/client.rb +162 -69
  13. data/lib/jenkins_api_client/exceptions.rb +26 -17
  14. data/lib/jenkins_api_client/job.rb +321 -75
  15. data/lib/jenkins_api_client/node.rb +22 -10
  16. data/lib/jenkins_api_client/plugin_manager.rb +460 -0
  17. data/lib/jenkins_api_client/urihelper.rb +17 -0
  18. data/lib/jenkins_api_client/user.rb +4 -2
  19. data/lib/jenkins_api_client/version.rb +3 -3
  20. data/lib/jenkins_api_client/view.rb +10 -7
  21. data/lib/jenkins_api_client.rb +1 -0
  22. data/scripts/login_with_pry.rb +54 -0
  23. data/spec/func_tests/client_spec.rb +3 -3
  24. data/spec/func_tests/job_spec.rb +90 -7
  25. data/spec/func_tests/{node_spec.rb → node_spec.rb.pending} +9 -9
  26. data/spec/func_tests/plugin_spec.rb +148 -0
  27. data/spec/unit_tests/client_spec.rb +108 -27
  28. data/spec/unit_tests/fake_http_response.rb +9 -0
  29. data/spec/unit_tests/fixtures/files/available_plugins.json +1 -0
  30. data/spec/unit_tests/fixtures/files/installed_plugins.json +1 -0
  31. data/spec/unit_tests/fixtures/files/updatable_plugins.json +1 -0
  32. data/spec/unit_tests/job_spec.rb +109 -6
  33. data/spec/unit_tests/node_spec.rb +18 -6
  34. data/spec/unit_tests/plugin_spec.rb +165 -0
  35. data/spec/unit_tests/spec_helper.rb +11 -1
  36. data/spec/unit_tests/system_spec.rb +2 -1
  37. data/spec/unit_tests/user_spec.rb +1 -1
  38. data/travis/hudson.model.UpdateCenter.xml +7 -0
  39. data/travis/setup.sh +2 -1
  40. metadata +76 -64
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 646dcb2b3b87533a3d3257a22b72b702efc3ebda
4
+ data.tar.gz: 87704990a77cc24b3eb6bee80c1a17837af36656
5
+ SHA512:
6
+ metadata.gz: 222f14e72886e6f13dea87e5cf98a24bd41ae1b1f655960b0245422cdcb340a8ba01ab72e0f327f5f39fb8cc0870c1246a5d0082a7ca52c08597e1dc44048e4f
7
+ data.tar.gz: 74573b0aaccfe06fe557c7d2c34500ff9e863c8af4bf3af7dcb7e4f2153e64c0361353e13944ee4e8d0be0fe0c802c8d1d84006331f4841bb6b2f6d6cbd720ca
data/.gitignore CHANGED
@@ -33,3 +33,6 @@ Gemfile.lock
33
33
  *.tmproj
34
34
  tmtags
35
35
  *.swp
36
+
37
+ # Skip the log file
38
+ jenkins_api_client.log
data/.travis.yml CHANGED
@@ -1,33 +1,15 @@
1
1
  language: ruby
2
+
2
3
  rvm:
3
4
  - 2.0.0
4
5
  - 1.9.3
5
- - jruby-18mode
6
- - jruby-19mode
7
- - rbx-18mode
8
- - rbx-19mode
9
- - 1.8.7
10
- - ree
11
- matrix:
12
- allow_failures:
13
- - rvm: jruby-18mode
14
- - rvm: jruby-19mode
15
- - rvm: rbx-18mode
16
- - rvm: rbx-19mode
17
- - rvm: ree
18
- before_install:
19
- - travis/setup.sh
20
6
 
21
7
  script:
22
8
  - bundle exec rake unit_tests
23
- - bundle exec rake func_tests
24
- - travis/setup_crumb.sh
25
- - bundle exec rake func_tests
9
+
26
10
  notifications:
27
11
  webhooks: https://www.buildheroes.com/api/projects/588c9dffdc8f0deff4d89d87bf370e8dba8a8a95/builds
28
- email: false
29
12
  irc:
30
- on_success: change
31
- on_failure: always
32
- channels:
33
- - "irc.freenode.org##jenins-api-client"
13
+ channels: ["chat.freenode.net##jenkins-api-client"]
14
+ use_notice: true
15
+ skip_join: true
data/CHANGELOG.md CHANGED
@@ -4,16 +4,42 @@ CHANGELOG
4
4
  upcoming
5
5
  --------
6
6
 
7
+ v1.0.0 [23-JUN-2014]
8
+ ----------------------
9
+ * Ruby 1.8 is not supported anymore.
10
+ * Added support for `PluginManager` which supports listing installed plugins,
11
+ available plugins, installing and uninstalling plugins, enabling and disabling
12
+ plugins, and more.
13
+ * Enhance URL escape.
14
+ * [#106][] Added support for obtaining build numbers after the build is posted for Jenkins
15
+ version pre 1.519, added callbacks while waiting and more. Credit: [@dougforpres][]
16
+ * [#112][] Added supported for obtaining information about promoted builds. Credit: [@dkerwin][]
17
+ * [#118][] Added support for specifying username/password in the URL. Credit: [@spikegrobstein][]
18
+ * [#119][] Added ability to execute groovy script on the Jenkins server. Credit: [@lheinlen-os][]
19
+ * [#122][] Updated the `create_dumb_slave` method to accept the new credentials id that is
20
+ introduced in the newer version of jenkins. Credit: [@Loa][]
21
+ * [#126][] Enabled the use of cookies for authentication. Credit: [@chilicheech][]
22
+ * [#127][] Do not set content type in api_post_request. Credit: [@chilicheech][]
23
+ * [#128][] Updated `exec_script` to use `api_post_reqeust` to support features provided by
24
+ `api_post_request` such as using crumbs. Credit: [@chilicheech][]
25
+ * [#132][] Allow copying and enabling jobs with spaces in them. Credit: [@mattrose][]
26
+ * [#134][] Added support for specifying HTTP open timeout. Credit: [@n-rodriguez][]
27
+ * [#136][] Prevent warnings due to Hash#[] call with nil items on Ruby 2.x. Credit: [@sunaot][]
28
+ * [#140][] Add require yaml in cli helper. Credit: [@riywo][]
29
+ * [#141][] Rename `create_dump_slave` -> `create_dumb_slave`. Thanks for finding the
30
+ typo/incorrect name [@cynipe][]
31
+
32
+
7
33
  v0.14.1 [18-AUG-2013]
8
34
  ----------------------
9
- * Fixed a bug in Job#create_or_update method. Credit: @bobbrez
35
+ * Fixed a bug in Job#create_or_update method. Credit: [@bobbrez][]
10
36
 
11
37
  v0.14.0 [07-AUG-2013]
12
38
  ----------------------
13
39
  * Fixed a bug where a space was missing in the exec_cli method argument list.
14
- Credit: @missedone
40
+ Credit: [@missedone][]
15
41
  * Refactored create/update jobs by introducing create_or_update methods.
16
- Credit: @riywo
42
+ Credit: [@riywo][]
17
43
  * Enhancement to crumb processing - auto detect the change of crumb setting and
18
44
  do proper exception handling. Credit: dougforpress
19
45
  * Added a `User` class which will handle jenkins users related functions.
@@ -37,38 +63,37 @@ v0.13.0 [09-JUL-2013]
37
63
  queue for longer than the 'timeout' parameter. This timeout parameter can be
38
64
  set during the client initialization.
39
65
  * Improved documentation
40
- * Support for enabling/disabling jobs. Credit: @dieterdemeyer
41
- * Added functionality for copying jobs. Credit: @dieterdemeyer
66
+ * Support for enabling/disabling jobs. Credit: [@dieterdemeyer][]
67
+ * Added functionality for copying jobs. Credit: [@dieterdemeyer][]
42
68
  * Added functionality for wiping out the workspace of a job.
43
- Credit: @dieterdemeyer
44
- * Added functionality for listing jenkins users. Credit: @dieterdemeyer
69
+ Credit: [@dieterdemeyer][]
70
+ * Added functionality for listing jenkins users. Credit: [@dieterdemeyer][]
45
71
  * Fixed a bug where the exceptions where not thrown when using the
46
72
  `get_console_output` method.
47
73
  * Fixed a bug where the jenkins_path attribute was ignored when the server_url
48
- input argument is given. Credit: @woodbusy
74
+ input argument is given. Credit: [@woodbusy][]
49
75
  * support public/private key pair authentication for Jenkins CLI.
50
- Credit: @missedone
76
+ Credit: [@missedone][]
51
77
 
52
78
 
53
79
  v0.12.1 [25-JUN-2013]
54
80
  ----------------------
55
81
  * Fixed a bug where the SSL support was not working properly with Ruby
56
- 1.8.7/JRuby 1.6. Credit: @brettporter (For more info:
57
- https://github.com/arangamani/jenkins_api_client/pull/85)
82
+ 1.8.7/JRuby 1.6. (Pull [#85][]) Credit: [@brettporter][]
58
83
 
59
84
  v0.12.0 [18-JUN-2013]
60
85
  ----------------------
61
86
  * Authentication is now optional as not all Jenkins instances have
62
- authentication enabled by default. Credit: @dougforpres
87
+ authentication enabled by default. Credit: [@dougforpres][]
63
88
  * Ability to retrieve build details so that more than just (`lamp color`) is
64
- available. Credit: @dougforpres
89
+ available. Credit: [@dougforpres][]
65
90
  * Ability to retrieve build test-results for those builds that have them.
66
- Credit: @dougforpres
91
+ Credit: [@dougforpres][]
67
92
  * Option to follow any 301/302 responses. This allows POST to build to follow
68
- the redirect and end up with a 200 response. Credit: @dougforpres
93
+ the redirect and end up with a 200 response. Credit: [@dougforpres][]
69
94
  * Minor change to the POST requests handling where jenkins instances with a
70
95
  proxy returns 411 if no form data is specified. Fixed by sending an empty
71
- hash. Credit: @dougforpres
96
+ hash. Credit: [@dougforpres][]
72
97
  * As of Jenkins release 1.519, the job build returns a 201 code instead of 302.
73
98
  This was resulting in an exception and the exception handling is modified to
74
99
  handle this condition.
@@ -78,17 +103,17 @@ v0.12.0 [18-JUN-2013]
78
103
  v0.11.0 [09-JUN-2013]
79
104
  ----------------------
80
105
  * A new input argument `server_url` is supported which accepts the jenkins URL
81
- instead of IP address and Port. Credit: @dieterdemeyer
82
- * When renaming the job, preserve the job history. Credit: @rubytester
83
- * Various exception handling improvements. Credit: @drnic
106
+ instead of IP address and Port. Credit: [@dieterdemeyer][]
107
+ * When renaming the job, preserve the job history. Credit: [@rubytester][]
108
+ * Various exception handling improvements. Credit: [@drnic][]
84
109
 
85
110
  v0.10.0 [24-APR-2013]
86
111
  ----------------------
87
- * new function to execute jenkins CLI `cli_exec`. Credit: @missedone
88
- * Add ability to use http proxy. Credit: @woodbusy
89
- * prompt the user for credentials when using irb login script. @woodbusy
90
- * bugfix for job.console_output. Credit: @drnic
91
- * add ssl support. Credit: @madisp
112
+ * new function to execute jenkins CLI `cli_exec`. Credit: [@missedone][]
113
+ * Add ability to use http proxy. Credit: [@woodbusy][]
114
+ * prompt the user for credentials when using irb login script. [@woodbusy][]
115
+ * bugfix for job.console_output. Credit: [@drnic][]
116
+ * add ssl support. Credit: [@madisp][]
92
117
 
93
118
  v0.9.1 [01-APR-2013]
94
119
  ---------------------
@@ -101,18 +126,18 @@ v0.9.0 [10-MAR-2013]
101
126
  * Removed warnings from client.rb
102
127
  * Refactored and improved exception handling
103
128
  * A bug is fixed in client which allows only the valid params as options.
104
- Credit: @Niarfe
129
+ Credit: [@Niarfe][]
105
130
  * Added a timeout parameter for waiting for jenkins to become ready.
106
- Credit: @Niarfe
107
- * Added function to reload jenkins. Credit: @missedone
131
+ Credit: [@Niarfe][]
132
+ * Added function to reload jenkins. Credit: [@missedone][]
108
133
  * Fixed a bug where jenkins_path was missing in get_config and post_config.
109
- Credit: @cylol
134
+ Credit: [@cylol][]
110
135
  * Added capability to obtain jenkins version and other useful information
111
136
  * Added new tests for various cases, and other code improvements
112
137
 
113
138
  v0.8.1 [15-FEB-2013]
114
139
  ---------------------
115
- * Fixed a bug in creating view. Issue #42
140
+ * Fixed a bug in creating view. Issue [#42][]
116
141
 
117
142
  v0.8.0 [14-FEB-2013]
118
143
  ---------------------
@@ -120,16 +145,16 @@ v0.8.0 [14-FEB-2013]
120
145
  * Added rename feature for jobs
121
146
  * Added support for sending skype notification in job creation and on existing
122
147
  jobs
123
- * Added support for sending Jenkins root URL configuration. Credit: @kevinhcross
148
+ * Added support for sending Jenkins root URL configuration. Credit: [@kevinhcross][]
124
149
  * Added `delete_all!` methods for Job, View, and Node.
125
150
  * `get_eta` in BuildQueue will return "N/A" if the ETA is not given by Jenkins
126
151
  * Creating view accepts params Hash and more configuration through the API
127
- * Spaces are allowed in Job, Node, and View names. Credit: @kevinhcross
128
- * Support has been added to build a job with parameters. Credit: @tjhanley
152
+ * Spaces are allowed in Job, Node, and View names. Credit: [@kevinhcross][]
153
+ * Support has been added to build a job with parameters. Credit: [@tjhanley][]
129
154
 
130
155
  v0.7.3 [05-FEB-2013]
131
156
  ---------------------
132
- * Fixed #27 with a bug in create_view including extra character in the end of
157
+ * Fixed [#27][] with a bug in create_view including extra character in the end of
133
158
  the name
134
159
 
135
160
  v0.7.2 [02-FEB-2013]
@@ -138,7 +163,7 @@ v0.7.2 [02-FEB-2013]
138
163
 
139
164
  v0.7.1 [30-JAN-2013]
140
165
  ---------------------
141
- * Fixed a bug (Issue #23) to remove the usage of "\" in Job.
166
+ * Fixed a bug (Issue [#23][]) to remove the usage of "\" in Job.
142
167
 
143
168
  v0.7.0 [27-JAN-2013]
144
169
  ---------------------
@@ -149,7 +174,7 @@ v0.7.0 [27-JAN-2013]
149
174
  * Added support for notification_email option when setting up a job
150
175
  * Added support for CVS provider in SCM
151
176
  * Added `create_dump_slave` and `delete` methods in Node API
152
- * Added BuildQueue class which is accessible by `@client.queue` method
177
+ * Added BuildQueue class which is accessible by `[@client][].queue` method
153
178
  * Improvements in all over the code for performance and error handling
154
179
 
155
180
  v0.6.2 [13-JAN-2013]
@@ -220,3 +245,47 @@ v0.0.2 [16-OCT-2012]
220
245
  v0.0.1 [15-OCT-2012]
221
246
  ---------------------
222
247
  * Initial Release
248
+
249
+
250
+ <!--- The following link definition list is generated by PimpMyChangelog --->
251
+ [#23]: https://github.com/arangamani/jenkins_api_client/issues/23
252
+ [#27]: https://github.com/arangamani/jenkins_api_client/issues/27
253
+ [#42]: https://github.com/arangamani/jenkins_api_client/issues/42
254
+ [#85]: https://github.com/arangamani/jenkins_api_client/issues/85
255
+ [#106]: https://github.com/arangamani/jenkins_api_client/issues/106
256
+ [#112]: https://github.com/arangamani/jenkins_api_client/issues/112
257
+ [#118]: https://github.com/arangamani/jenkins_api_client/issues/118
258
+ [#119]: https://github.com/arangamani/jenkins_api_client/issues/119
259
+ [#122]: https://github.com/arangamani/jenkins_api_client/issues/122
260
+ [#126]: https://github.com/arangamani/jenkins_api_client/issues/126
261
+ [#127]: https://github.com/arangamani/jenkins_api_client/issues/127
262
+ [#128]: https://github.com/arangamani/jenkins_api_client/issues/128
263
+ [#132]: https://github.com/arangamani/jenkins_api_client/issues/132
264
+ [#134]: https://github.com/arangamani/jenkins_api_client/issues/134
265
+ [#136]: https://github.com/arangamani/jenkins_api_client/issues/136
266
+ [#140]: https://github.com/arangamani/jenkins_api_client/issues/140
267
+ [#141]: https://github.com/arangamani/jenkins_api_client/issues/141
268
+ [@Loa]: https://github.com/Loa
269
+ [@Niarfe]: https://github.com/Niarfe
270
+ [@bobbrez]: https://github.com/bobbrez
271
+ [@brettporter]: https://github.com/brettporter
272
+ [@chilicheech]: https://github.com/chilicheech
273
+ [@client]: https://github.com/client
274
+ [@cylol]: https://github.com/cylol
275
+ [@cynipe]: https://github.com/cynipe
276
+ [@dieterdemeyer]: https://github.com/dieterdemeyer
277
+ [@dkerwin]: https://github.com/dkerwin
278
+ [@dougforpres]: https://github.com/dougforpres
279
+ [@drnic]: https://github.com/drnic
280
+ [@kevinhcross]: https://github.com/kevinhcross
281
+ [@lheinlen-os]: https://github.com/lheinlen-os
282
+ [@madisp]: https://github.com/madisp
283
+ [@mattrose]: https://github.com/mattrose
284
+ [@missedone]: https://github.com/missedone
285
+ [@n-rodriguez]: https://github.com/n-rodriguez
286
+ [@riywo]: https://github.com/riywo
287
+ [@rubytester]: https://github.com/rubytester
288
+ [@spikegrobstein]: https://github.com/spikegrobstein
289
+ [@sunaot]: https://github.com/sunaot
290
+ [@tjhanley]: https://github.com/tjhanley
291
+ [@woodbusy]: https://github.com/woodbusy
data/CONTRIBUTORS.md CHANGED
@@ -1,13 +1,3 @@
1
1
  Thank you very much to all who contributed to this project.
2
2
 
3
- * [Niarfe](https://github.com/Niarfe)
4
- * [dieterdemeyer](https://github.com/dieterdemeyer)
5
- * [kevinhcross](https://github.com/kevinhcross)
6
- * [drnic](https://github.com/drnic)
7
- * [woodbusy](https://github.com/woodbusy)
8
- * [missedone](https://github.com/missedone)
9
- * [cylol](https://github.com/cylol)
10
- * [madisp](https://github.com/madisp)
11
- * [rubytester](https://github.com/rubytester)
12
- * [dougforpres](https://github.com/dougforpres)
13
- * [brettporter](https://github.com/brettporter)
3
+ Please visit the [Contributors](https://github.com/arangamani/jenkins_api_client/graphs/contributors) page on Github.
data/Gemfile CHANGED
@@ -1,6 +1,6 @@
1
1
  source "https://rubygems.org"
2
2
 
3
- gem "nokogiri", "~> 1.5.0"
3
+ gem "nokogiri", "~> 1.6.0"
4
4
  gem "thor", ">= 0.16.0"
5
5
  gem "json", ">= 0"
6
6
  gem "terminal-table", ">= 1.4.0"
@@ -9,7 +9,9 @@ gem "mixlib-shellout", ">= 1.1.0"
9
9
  group :development do
10
10
  gem "bundler", ">= 1.0"
11
11
  gem "jeweler", ">= 1.6.4"
12
- gem "rspec", "~> 2.13.0"
12
+ gem "rspec", "~> 2.14.1"
13
13
  gem "simplecov"
14
+ gem "yard-thor"
14
15
  gem "yard"
16
+ gem "pry"
15
17
  end
data/README.md CHANGED
@@ -1,9 +1,15 @@
1
1
  Jenkins API Client
2
2
  ==================
3
- [![Gem Version](https://badge.fury.io/rb/jenkins_api_client.png)](http://rubygems.org/gems/jenkins_api_client)
4
- [![Build Status](https://travis-ci.org/arangamani/jenkins_api_client.png?branch=master)](https://travis-ci.org/arangamani/jenkins_api_client)
5
- [![Dependency Status](https://gemnasium.com/arangamani/jenkins_api_client.png)](https://gemnasium.com/arangamani/jenkins_api_client)
6
- [![Code Climate](https://codeclimate.com/github/arangamani/jenkins_api_client.png)](https://codeclimate.com/github/arangamani/jenkins_api_client)
3
+
4
+ [![Gem Version](http://img.shields.io/gem/v/jenkins_api_client.svg)][gem]
5
+ [![Build Status](http://img.shields.io/travis/arangamani/jenkins_api_client.svg)][travis]
6
+ [![Dependency Status](http://img.shields.io/gemnasium/arangamani/jenkins_api_client.svg)][gemnasium]
7
+ [![Code Climate](http://img.shields.io/codeclimate/github/arangamani/jenkins_api_client.svg)][codeclimate]
8
+
9
+ [gem]: https://rubygems.org/gems/jenkins_api_client
10
+ [travis]: http://travis-ci.org/arangamani/jenkins_api_client
11
+ [gemnasium]: https://gemnasium.com/arangamani/jenkins_api_client
12
+ [codeclimate]: https://codeclimate.com/github/arangamani/jenkins_api_client
7
13
 
8
14
  Copyright &copy; 2012-2013, Kannan Manickam [![endorse](http://api.coderwall.com/arangamani/endorsecount.png)](http://coderwall.com/arangamani)
9
15
 
@@ -67,6 +73,14 @@ file. To use the client without credentials, just leave out the
67
73
  <tt>username</tt> and <tt>password</tt> parameters. The <tt>password</tt>
68
74
  parameter is only required if <tt>username</tt> is specified.
69
75
 
76
+ #### Using with Open ID
77
+
78
+ It is very simple to authenticate with your Jenkins server that has Open ID
79
+ authentication enabled. You will have to obtain your API token and use the API
80
+ token as the password. For obtaining the API token, go to your user configuration
81
+ page and click 'Show API Token'. Use this token for the `password` parameter when
82
+ initializing the client.
83
+
70
84
  ### Cross-site Scripting (XSS) and Crumb Support
71
85
 
72
86
  Support for Jenkins crumbs has been added. These allow an application to
@@ -102,7 +116,7 @@ puts @client.job.list_all
102
116
  ### Chaining and Building Jobs
103
117
 
104
118
  Sometimes we want certain jobs to be added as downstream projects and run them
105
- sequencially. The following example will explain how this could be done.
119
+ sequentially. The following example will explain how this could be done.
106
120
 
107
121
  ```ruby
108
122
  require 'jenkins_api_client'
@@ -169,6 +183,87 @@ initial_jobs.each do |job|
169
183
  end
170
184
  ```
171
185
 
186
+ ### Waiting for a build to start/Getting the build number
187
+ Newer versions of Jenkins (starting with the 1.519 build) make it easier for
188
+ an application to determine the build number for a 'build' request. (previously
189
+ there would be a degree of guesswork involved). The new version actually
190
+ returns information allowing the jenkins_api_client to check the build queue
191
+ for the job and see if it has started yet (once it has started, the build-
192
+ number is available.
193
+
194
+ If you wish to take advantage of this hands-off approach, the build method
195
+ supports an additional 'opts' hash that lets you specify how long you wish to
196
+ wait for the build to start.
197
+
198
+ #### Old Jenkins vs New Jenkins (1.519+)
199
+
200
+ ##### Old (v < 1.519)
201
+ The 'opts' parameter will work with older versions of Jenkins with the following
202
+ caveats:
203
+ * The 'cancel_on_build_start_timeout' option has no effect
204
+ * The build_number is calculated by calling 'current_build_number' and adding
205
+ 1 before the build is started. This might break if there are multiple
206
+ entities running builds on the same job, or there are queued builds.
207
+
208
+ ##### New (v >= 1.519)
209
+ * All options work, and build number is accurately determined from queue
210
+ info.
211
+
212
+ #### Initiating a build and returning the build_number
213
+
214
+ ##### Minimum required
215
+ ```ruby
216
+ # Minimum options required
217
+ opts = {'build_start_timeout' => 30}
218
+ @client.job.build(job_name, job_params || {}, opts)
219
+ ```
220
+ This method will block for up to 30 seconds, while waiting for the build to
221
+ start. Instead of returning an http-status code, it will return the
222
+ build_number, or if the build has not started will raise 'Timeout::Error'
223
+ Note: to maintain legacy compatibility, passing 'true' will set the timeout
224
+ to the default timeout specified when creating the @client.
225
+
226
+ ##### Auto cancel the queued-build on timeout
227
+ ```ruby
228
+ # Wait for up to 30 seconds, attempt to cancel queued build
229
+ opts = {'build_start_timeout' => 30,
230
+ 'cancel_on_build_start_timeout' => true}
231
+ @client.job.build(job_name, job_params || {}, opts)
232
+ ```
233
+ This method will block for up to 30 seconds, while waiting for the build to
234
+ start. Instead of returning an http-status code, it will return the
235
+ build_number, or if the build has not started will raise 'Timeout::Error'.
236
+ Prior to raising the Timeout::Error, it will attempt to cancel the queued
237
+ build - thus preventing it from starting.
238
+
239
+ ##### Getting some feedback while you're waiting
240
+ The opts parameter supports two values that can be assigned proc objects
241
+ (which will be 'call'ed). Both are optional, and will only be called if
242
+ specified in opts.
243
+ These are initially intended to assist with logging progress.
244
+
245
+ * 'progress_proc' - called when job is initially queued, and periodically
246
+ thereafter.
247
+ * max_wait - the value of 'build_start_timeout'
248
+ * current_wait - how long we've been waiting so far
249
+ * poll_count - how many times we've polled the queue
250
+ * 'completion_proc' - called just prior to return/Timeout::Error
251
+ * build_number - the build number assigned (or nil if timeout)
252
+ * cancelled - whether the build was cancelled (true if 'new' Jenkins
253
+ and it was able to cancel the build, false otherwise)
254
+
255
+ To use a class method, just specify 'instance.method(:method_name)', or
256
+ use a proc or lambda
257
+
258
+ ```ruby
259
+ # Wait for up to 30 seconds, attempt to cancel queued build, progress
260
+ opts = {'build_start_timeout' => 30,
261
+ 'cancel_on_build_start_timeout' => true,
262
+ 'poll_interval' => 2, # 2 is actually the default :)
263
+ 'progress_proc' => lambda {|max,curr,count| ... },
264
+ 'completion_proc' => lambda {|build_number,cancelled| ... }}
265
+ @client.job.build(job_name, job_params || {}, opts)
266
+ ```
172
267
  ### Running Jenkins CLI
173
268
  To running [Jenkins CLI](https://wiki.jenkins-ci.org/display/JENKINS/Jenkins+CLI)
174
269
 
@@ -182,8 +277,9 @@ puts @client.exec_cli("version")
182
277
  ```
183
278
 
184
279
  * authentication with public/private key file
185
- remember to upload the public key to
186
- http://<Server IP>:<Server Port>/user/<Username>/configure
280
+ remember to upload the public key to:
281
+
282
+ `http://#{Server IP}:#{Server Port}/user/#{Username}/configure`
187
283
 
188
284
  ```ruby
189
285
  @client = JenkinsApi::Client.new(:server_ip => '127.0.0.1',
@@ -270,3 +366,7 @@ FEATURE REQUEST:
270
366
  If you use this gem for your project and you think it would be nice to have a
271
367
  particular feature that is presently not implemented, I would love to hear that
272
368
  and consider working on it. Just open an issue in Github as a feature request.
369
+
370
+
371
+ [![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/arangamani/jenkins_api_client/trend.png)](https://bitdeli.com/free "Bitdeli Badge")
372
+
data/Rakefile CHANGED
@@ -22,6 +22,7 @@ Jeweler::Tasks.new do |gemspec|
22
22
  This is a simple and easy-to-use Jenkins Api client with features focused on
23
23
  automating Job configuration programaticaly and so forth}
24
24
  gemspec.test_files = `git ls-files -- {spec}/*`.split("\n")
25
+ gemspec.required_ruby_version = '>= 1.9.2'
25
26
  gemspec.rubygems_version = '1.8.17'
26
27
  end
27
28
 
data/Vagrantfile CHANGED
@@ -9,11 +9,11 @@ Vagrant.configure("2") do |config|
9
9
  config.vm.hostname = "jenkins-api-client"
10
10
 
11
11
  # Every Vagrant virtual environment requires a box to build off of.
12
- config.vm.box = "Ubuntu-12.04-LTS"
12
+ config.vm.box = "opscode-ubuntu-12.04"
13
13
 
14
14
  # The url from where the 'config.vm.box' box will be fetched if it
15
15
  # doesn't already exist on the user's system.
16
- config.vm.box_url = "https://s3-us-west-2.amazonaws.com/squishy.vagrant-boxes/precise64_squishy_2013-02-09.box"
16
+ config.vm.box_url = "https://opscode-vm-bento.s3.amazonaws.com/vagrant/opscode_ubuntu-12.04_provisionerless.box"
17
17
 
18
18
  # Assign this VM to a host-only network IP, allowing you to access it
19
19
  # via the IP. Host-only networks can talk to the host machine as well as
@@ -52,9 +52,6 @@ Vagrant.configure("2") do |config|
52
52
  # View the documentation for the provider you're using for more
53
53
  # information on available options.
54
54
 
55
- config.ssh.max_tries = 40
56
- config.ssh.timeout = 120
57
-
58
55
  # The path to the Berksfile to use with Vagrant Berkshelf
59
56
  # config.berkshelf.berksfile_path = "./Berksfile"
60
57
 
@@ -73,11 +70,12 @@ Vagrant.configure("2") do |config|
73
70
  config.vm.synced_folder ".", "/opt/jenkins_api_client"
74
71
 
75
72
  config.vm.provision :shell, :inline =>
76
- " sudo apt-get install -y git rubygems libxslt-dev libxml2-dev;" +
73
+ " sudo apt-get update;" +
74
+ " sudo apt-get install -y git ruby1.9.1-full rubygems libxslt-dev libxml2-dev;" +
77
75
  " cd /opt/jenkins_api_client;" +
78
76
  " ls -lrt;" +
79
- " ruby --version;" +
80
- " sudo gem install bundler;" +
77
+ " ruby1.9.1 --version;" +
78
+ " sudo gem1.9.1 install bundler;" +
81
79
  " bundle install;" +
82
80
  " travis/setup.sh;" +
83
81
  " bundle exec rake unit_tests;" +
@@ -2,14 +2,16 @@
2
2
  # DO NOT EDIT THIS FILE DIRECTLY
3
3
  # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
4
  # -*- encoding: utf-8 -*-
5
+ # stub: jenkins_api_client 1.0.0 ruby lib
5
6
 
6
7
  Gem::Specification.new do |s|
7
8
  s.name = "jenkins_api_client"
8
- s.version = "0.14.1"
9
+ s.version = "1.0.0"
9
10
 
10
11
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
12
+ s.require_paths = ["lib"]
11
13
  s.authors = ["Kannan Manickam"]
12
- s.date = "2013-08-19"
14
+ s.date = "2014-06-21"
13
15
  s.description = "\nThis is a simple and easy-to-use Jenkins Api client with features focused on\nautomating Job configuration programaticaly and so forth"
14
16
  s.email = ["arangamani.kannan@gmail.com"]
15
17
  s.executables = ["jenkinscli"]
@@ -40,28 +42,38 @@ Gem::Specification.new do |s|
40
42
  "lib/jenkins_api_client/exceptions.rb",
41
43
  "lib/jenkins_api_client/job.rb",
42
44
  "lib/jenkins_api_client/node.rb",
45
+ "lib/jenkins_api_client/plugin_manager.rb",
43
46
  "lib/jenkins_api_client/system.rb",
47
+ "lib/jenkins_api_client/urihelper.rb",
44
48
  "lib/jenkins_api_client/user.rb",
45
49
  "lib/jenkins_api_client/version.rb",
46
50
  "lib/jenkins_api_client/view.rb",
47
51
  "scripts/login_with_irb.rb",
52
+ "scripts/login_with_pry.rb",
48
53
  "spec/func_tests/client_spec.rb",
49
54
  "spec/func_tests/job_spec.rb",
50
- "spec/func_tests/node_spec.rb",
55
+ "spec/func_tests/node_spec.rb.pending",
56
+ "spec/func_tests/plugin_spec.rb",
51
57
  "spec/func_tests/spec_helper.rb",
52
58
  "spec/func_tests/system_spec.rb",
53
59
  "spec/func_tests/user_spec.rb",
54
60
  "spec/func_tests/view_spec.rb",
55
61
  "spec/unit_tests/build_queue_spec.rb",
56
62
  "spec/unit_tests/client_spec.rb",
63
+ "spec/unit_tests/fake_http_response.rb",
64
+ "spec/unit_tests/fixtures/files/available_plugins.json",
57
65
  "spec/unit_tests/fixtures/files/computer_sample.xml",
66
+ "spec/unit_tests/fixtures/files/installed_plugins.json",
58
67
  "spec/unit_tests/fixtures/files/job_sample.xml",
68
+ "spec/unit_tests/fixtures/files/updatable_plugins.json",
59
69
  "spec/unit_tests/job_spec.rb",
60
70
  "spec/unit_tests/node_spec.rb",
71
+ "spec/unit_tests/plugin_spec.rb",
61
72
  "spec/unit_tests/spec_helper.rb",
62
73
  "spec/unit_tests/system_spec.rb",
63
74
  "spec/unit_tests/user_spec.rb",
64
75
  "spec/unit_tests/view_spec.rb",
76
+ "travis/hudson.model.UpdateCenter.xml",
65
77
  "travis/jenkins_config.xml",
66
78
  "travis/jenkins_config_with_crumb.xml",
67
79
  "travis/setup.sh",
@@ -70,47 +82,53 @@ Gem::Specification.new do |s|
70
82
  "travis/user_config.xml"
71
83
  ]
72
84
  s.homepage = "https://github.com/arangamani/jenkins_api_client"
73
- s.require_paths = ["lib"]
74
- s.rubygems_version = "1.8.23"
85
+ s.required_ruby_version = Gem::Requirement.new(">= 1.9.2")
86
+ s.rubygems_version = "2.2.2"
75
87
  s.summary = "Jenkins JSON API Client"
76
88
 
77
89
  if s.respond_to? :specification_version then
78
- s.specification_version = 3
90
+ s.specification_version = 4
79
91
 
80
92
  if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
81
- s.add_runtime_dependency(%q<nokogiri>, ["~> 1.5.0"])
93
+ s.add_runtime_dependency(%q<nokogiri>, ["~> 1.6.0"])
82
94
  s.add_runtime_dependency(%q<thor>, [">= 0.16.0"])
83
95
  s.add_runtime_dependency(%q<json>, [">= 0"])
84
96
  s.add_runtime_dependency(%q<terminal-table>, [">= 1.4.0"])
85
97
  s.add_runtime_dependency(%q<mixlib-shellout>, [">= 1.1.0"])
86
98
  s.add_development_dependency(%q<bundler>, [">= 1.0"])
87
99
  s.add_development_dependency(%q<jeweler>, [">= 1.6.4"])
88
- s.add_development_dependency(%q<rspec>, ["~> 2.13.0"])
100
+ s.add_development_dependency(%q<rspec>, ["~> 2.14.1"])
89
101
  s.add_development_dependency(%q<simplecov>, [">= 0"])
102
+ s.add_development_dependency(%q<yard-thor>, [">= 0"])
90
103
  s.add_development_dependency(%q<yard>, [">= 0"])
104
+ s.add_development_dependency(%q<pry>, [">= 0"])
91
105
  else
92
- s.add_dependency(%q<nokogiri>, ["~> 1.5.0"])
106
+ s.add_dependency(%q<nokogiri>, ["~> 1.6.0"])
93
107
  s.add_dependency(%q<thor>, [">= 0.16.0"])
94
108
  s.add_dependency(%q<json>, [">= 0"])
95
109
  s.add_dependency(%q<terminal-table>, [">= 1.4.0"])
96
110
  s.add_dependency(%q<mixlib-shellout>, [">= 1.1.0"])
97
111
  s.add_dependency(%q<bundler>, [">= 1.0"])
98
112
  s.add_dependency(%q<jeweler>, [">= 1.6.4"])
99
- s.add_dependency(%q<rspec>, ["~> 2.13.0"])
113
+ s.add_dependency(%q<rspec>, ["~> 2.14.1"])
100
114
  s.add_dependency(%q<simplecov>, [">= 0"])
115
+ s.add_dependency(%q<yard-thor>, [">= 0"])
101
116
  s.add_dependency(%q<yard>, [">= 0"])
117
+ s.add_dependency(%q<pry>, [">= 0"])
102
118
  end
103
119
  else
104
- s.add_dependency(%q<nokogiri>, ["~> 1.5.0"])
120
+ s.add_dependency(%q<nokogiri>, ["~> 1.6.0"])
105
121
  s.add_dependency(%q<thor>, [">= 0.16.0"])
106
122
  s.add_dependency(%q<json>, [">= 0"])
107
123
  s.add_dependency(%q<terminal-table>, [">= 1.4.0"])
108
124
  s.add_dependency(%q<mixlib-shellout>, [">= 1.1.0"])
109
125
  s.add_dependency(%q<bundler>, [">= 1.0"])
110
126
  s.add_dependency(%q<jeweler>, [">= 1.6.4"])
111
- s.add_dependency(%q<rspec>, ["~> 2.13.0"])
127
+ s.add_dependency(%q<rspec>, ["~> 2.14.1"])
112
128
  s.add_dependency(%q<simplecov>, [">= 0"])
129
+ s.add_dependency(%q<yard-thor>, [">= 0"])
113
130
  s.add_dependency(%q<yard>, [">= 0"])
131
+ s.add_dependency(%q<pry>, [">= 0"])
114
132
  end
115
133
  end
116
134
 
@@ -21,6 +21,7 @@
21
21
  #
22
22
 
23
23
  require 'fileutils'
24
+ require 'yaml'
24
25
 
25
26
  module JenkinsApi
26
27
  module CLI