Class: JenkinsApi::Client::System
- Inherits:
-
Object
- Object
- JenkinsApi::Client::System
- Defined in:
- lib/jenkins_api_client/system.rb
Overview
This class is used to communicate with Jenkins and performing some admin level operations such as restarting and reloading Jenkins.
Instance Method Summary collapse
-
#cancel_quiet_down ⇒ Object
Cancels the quiet doen request sent to the server.
-
#initialize(client) ⇒ System
constructor
Initializes a new System object.
-
#quiet_down ⇒ Object
Sends a quiet down request to the server.
-
#reload ⇒ Object
Reload the Jenkins server.
-
#restart(force = false) ⇒ Object
Restarts the Jenkins server.
-
#to_s ⇒ Object
Returns a string representation of System class.
-
#wait_for_ready ⇒ Object
This method waits till the server becomes ready after a start or restart.
Constructor Details
#initialize(client) ⇒ System
Initializes a new System object.
36 37 38 |
# File 'lib/jenkins_api_client/system.rb', line 36 def initialize(client) @client = client end |
Instance Method Details
#cancel_quiet_down ⇒ Object
Cancels the quiet doen request sent to the server.
54 55 56 |
# File 'lib/jenkins_api_client/system.rb', line 54 def cancel_quiet_down @client.api_post_request("/cancelQuietDown") end |
#quiet_down ⇒ Object
Sends a quiet down request to the server.
48 49 50 |
# File 'lib/jenkins_api_client/system.rb', line 48 def quiet_down @client.api_post_request("/quietDown") end |
#reload ⇒ Object
Reload the Jenkins server
73 74 75 |
# File 'lib/jenkins_api_client/system.rb', line 73 def reload @client.api_post_request("/reload") end |
#restart(force = false) ⇒ Object
Restarts the Jenkins server
63 64 65 66 67 68 69 |
# File 'lib/jenkins_api_client/system.rb', line 63 def restart(force = false) if force @client.api_post_request("/restart") else @client.api_post_request("/safeRestart") end end |
#to_s ⇒ Object
Returns a string representation of System class.
42 43 44 |
# File 'lib/jenkins_api_client/system.rb', line 42 def to_s "#<JenkinsApi::Client::System>" end |
#wait_for_ready ⇒ Object
This method waits till the server becomes ready after a start or restart.
80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 |
# File 'lib/jenkins_api_client/system.rb', line 80 def wait_for_ready Timeout::timeout(@client.timeout) do while true do response = @client.get_root puts "[INFO] Waiting for jenkins to restart..." if @client.debug if (response.body =~ /Please wait while Jenkins is restarting/ || response.body =~ /Please wait while Jenkins is getting ready to work/) sleep 30 redo else return true end end end false end |