I have 13 window servers running Jenkins Slaves. For some reason (Windows updates?), The Jenkins Slaves periodically stop working, and the Slave Jenkins service needs to be restarted. If I manually SSH for machines (the cygwin ssh server is running), I simply print:
net stop "Jenkins Slave" net start "Jenkins Slave"
and that (almost) always solves the problem.
So, I wrote a Ruby script to automate this.
That's what:
#!/usr/bin/env ruby require 'rubygems' require 'net/ssh' USER = 'Administrator' PASS = 'PASSWORD' hosts = [:breckenridge, :carbondale, :crestone, :denali, :gunnison, :sneffels, "mammoth", "whitney", "snowmass", "firestone", "avon", :grizzly, :silverton] hosts.each {|host| puts "SSHing #{host} ..." Net::SSH.start( HOST, USER, :password => PASS ) do |ssh| puts ssh.exec!('net stop "Jenkins Slave"') puts ssh.exec!('net start "Jenkins Slave"') puts "Logging out..." end }
the script runs on all machines, I see the output that the service started. However, this never works. When I get back to the car, the service did not start.
Unfortunately, I cannot use Linux - I do not control these machines.
Any ideas on why SSH works manually but the script doesn't work?
Thanks phil
windows ruby ssh jenkins
phil swenson
source share