Unable to reconnect jenkins slave automatically after restart - windows

I have a Jenkins master (Linux Debian) and 4 slaves (Windows 7) which are connected via JNLP.
The jenkins slave service works well in each slave. However when I restart a slave machine, the connection breaks down for all the slaves and the reconnection is established again only if the Jenkins master is restarted.
What should I do?

I solved the issue with the following command:
sc triggerinfo <service_name_of_jenkins_slave> start/networkon stop/networkoff

You may need to install the slave as a windows service.
https://wiki.jenkins-ci.org/display/JENKINS/Installing+Jenkins+as+a+Windows+service
update:
Installation as a task
If for some reason the service crashes a lot, you may want to install a task to start jenkins slave through the task scheduler.
right click on computer (either on desktop icon or menu option)
find the task scheduler
create a basic task
follow the other steps from this wiki.

Related

Using a Windows VM from Jenkins through vsphere

I'm trying to reset-and-launch a Windows VM (in vsphere) during a Jenkins job. I successfully installed the vSphere Cloud Plugin. I've followed instructions to setup the Windows machine as a jenkins-mvn-slave, and have it setup to run as a service.
If I click on the button in Jenkins for Launch Slave Agent, I can see (in vsphere) that the VM does a revert snapshot, and then it does a power on virtual machine. If I attach to the machine, I can see that the Jenkins service starts automatically. However, back in Jenkins, it tells me that the Slave did not come online in allowed time.
Some key settings for my slave:
Force VM launch: Checked
Wait for VMTools: Not checked
Delay between launch and boot complete: 120
Secondary launch method: Launch slave agents view Java Web Start
Versions:
Jenkins: 1.596.2
vSphere: 5.5.0
Windows: Server 2012 R2 Standard, Build 9600
vSphere plugin: 2.7
What am I missing?
I've done a lot of messing around since I posted, but I think the following is what I was doing wrong. I first got the VM working as a normal slave agent. Once I had that working, then I tried to setup the same as a vsphere-cloud-slave-agent. I wasn't realizing that setting up a host as a slave agent is "agent-name specific".
So, I uninstalled the Jenkins service, launched the "vsphere cloud slave agent", logged into the machine, and ran javaws (as specified in the previously mentioned instructions.
A couple of other gotchas that I encountered (not relevant to the initial post, but maybe relevant to someone who reads this):
I originally installed git with a password manager. Unfortunately, since jenkins jobs aren't interactive, it was hanging on the git clone command. I tried uninstalling and re-installing git, but it didn't fix the problem for whatever user the jenkins slave was running as. I ended up having to revert to a previous slave image and install git from there. (I probably could have also figured out what user was running the jenkins slave, and entered the desired password there.)
I wanted to run a clean VM for each job. I never figured out this one. If I set Availability to Take this slave on-line when in demand and off-line when idle, that was a good start. However, if I set the times to 0 and 0, then the machine was constantly rebooting. If I set the times to 1 and 1, then the machine does mostly what I want, unless there are back-to-back jobs queued to run.

Jenkins doesn't recognize slave being down and thus does not allow for it to reconnect

We have a Jenkins instance running on Ubuntu that has several slaves in different systems. One of them is a Windows 7 host, having jenkins slave instance configured as a service.
We have a problem that when that machine is rebooted, master Jenkins doesn't realize it's gone. It looks to be just fine in the nodes view. Then, when a build is issued that is supposed to use that slave it gets stuck. If that is stopped, the next build fails immediately
Caused by: java.util.concurrent.TimeoutException: Ping started at 1457016721684 hasn't completed by 1457016961684
... 2 more
[EnvInject] - [ERROR] - SEVERE ERROR occurs: channel is already closed
When the slave has started up and it tries to connect back to master, connection is refused, and in the logs there is an error saying connection with that name already exists:
Server didn't accept the handshake: xxx is already connected to this master. Rejecting this connection.
There is issue JENKINS-5055 which claims a fix was committed allowing the same JNLP slave to reconnect without getting rejected, apparently this commit, and according to changelog, it was introduced in version 1.396 (2011/02/02). We are however using version 1.639 and seeing this. Somebody else seems to be seeing it as well. By looking at current codebase, I see where the error is coming from, but don't see the fix done in Jenkins-5055.
Any ideas on resolving this?
Edit: also asked on jenkins user mailing list, but no responses.
We faced the same issue. Used https://wiki.jenkins-ci.org/display/JENKINS/slave-status as workaround
Reinstalling the slave on a Windows Server 2012 R2 machine shows no signs of this behavior, so it seems that either there was a mistake done during installation steps or this is something caused by using a workstation Windows version.
Regardless, here were the steps to get it working, assuming a brand new installation of Windows, with no network connectivity, and master instance using a self-signed certificate:
Install JRE on the machine. If you have 64-bit operating system, install both 32-bit and 64-bit, otherwise go with 32-bit. Download link here
Install .NET 3.5 on the machine. This is needed by the Jenkins service. You can follow the steps outlined by my other answer for this.
Install Jenkins using Windows installer (.zipped) to C:\Jenkins. It can be downloaded from here.
Check your installation is responding by navigating to http://localhost:8080 . In case of trouble, check for logs in the jenkins folder. If there is a port conflict, edit jenkins.xml and change the httpPort to something else.
From the Windows computer, navigate to your master jenkins and configure a new node there.
Start a slave agent using Java Launch Agent in configure -> node screen (you need to be still using your Windows slave computer)
You should see a visible window opening. From there, select File -> Install as a service. (details and screenshots) If you experience an error without proper explanation, confirm .NET 3.5 is properly installed. If you see "WMI.WmiException: AccessDenied", save the jnlp file locally and start it from administrator prompt or otherwise with elevated privileges (details).
From the Administrative tools -> Services, stop and disable the Jenkins service, and stop Jenkins Slave Agent but leave it on Automatic so it will start up when starting up the computer.
This is only relevant if you're using a self-signed or otherwise problematic certificate:
download the previously mentioned Java Launch Agent file (.jnlp file) again and save it to C:\jenkins
open c:\jenkins\jenkins-slave.xml to your editor
change it to refer to your local .jnlp file by changing jnlp url parameter (file:/C:/jenkins/jenkins-slave.jnlp)
add -noCertificateCheck to parameters
replace the -secret parameter with -auth "user:pass", since otherwise automatic url get parameters will be added which will mess finding the .jnlp file
Start the Jenkins Slave Agent service again
For problems with jenkins slave service, check out jenkins-slave.err.log. For Windows Server 2012 R2, you can get the functionality of tail by using Get-Content .\jenkins-slave.err.log -Wait -Tail 10 in Powershell prompt. For older versions of Powershell, leave out -Tail 10.

Jenkins Windows slave gives Unexpected Error with JNLP start

I have a Jenkins server running happily on a Windows server. I need to connect 2 other windows servers as slaves.
One connects in fine (start using JNLP, then installed as a Windows service).
The other fails to connect using JNLP. Whether I use the Launch button or the javaws command line it fails with 'Unexpected Error - Unable to launch Slave Agent for {node}'. If I start the slave using the headless command line it works, so I suspect it's not networking/firewall related.
I'd like to get the JNLP launch working so I can install it as a Windows service.
Other notes:
the Jenkins URL is set OK
we're using Matrix security, but anonymous has Slave/Connect
Any help gratefully received.

Cannot install jenkins slave on a windows machine

I am a very newbie to Jenkins ,
I am trying to Lunch a slave via Java Web Start, and when i try to install the Jenkins slave knowing that the master address is as follow http://masterdomain.com i see that the slave tries to connect to http://masterdomain.com:54999 , any ideas why this happens
Jenkins uses a special port for connections between the slave and the master. By default the port number is variable, but if you have a firewall between the master and the slave you can fix the port number via the URL <your Jenkins master URL>/configureSecurity/
Hey to answer your question from the comments above, the MASTER URL for jenkins is configured in the Manage Jenkins --> Configure System --> Jenkins Location
The Java Web start tries to get the URL from this location setting and uses it to setup the JNLP Agent on the slave.
Hope this helps.

How to force Jenkins to launch webpage/ cmd prompt in client (user's) machine?

The job that I was trying to create in Jenkins would require launching a webpage on the user’s browser once the build is successful (Jenkins is installed on a remote server). For doing this I put the following line in the " Build - Execute Windows batch command" section of the job’s Configure page:
START http://google.com
While the build was successful, it did not launch the page. I have a hunch, this line will try to launch the webpage in the remote Jenkins server (it did not launch anything in the slave node though). My question is, how do I force the Jenkins job to launch the webpage in the user’s default browser?
I tried launching client's cmd.exe - this did not work either.
Jenkins master, slave, user's client - everything is on Windows. Jenkins version 1.46.
Thanks!
By "launch in client's machine" you mean the user that is accessing the web interface of Jenkins? No, this won't happen. It can be quite a security risk too.
You can do what you are asking either on the master or the slave. Jenkins does not directly execute anything that is not on master/slave. It is possible to spawn a slave on user's machine, and when the job is run, it will execute the command on the slave.
Or if the user provides his/her computer IP address as a parameter to the job, you could use PsExec to connect to user's computer to execute a command.

Resources