Jenkins slave is going offline - jenkins

I have Jenkins slaves connected with master and after some intervals my Jenkins slave is going to offline and whenever its going to offline I am manually running the Jnlp command(Run from slave command line:
java -jar slave.jar -jnlpUrl http://abc.ap.com:8080/computer/Wkaakkaak/slave-agent.jnlp -secret af95sdsda051229eb57b1d51202e5cf986a1cbcfbb2e0a5130d915ba037297a0 ) in slave machine to connect with master but every time I can't login to slave and run the command.Is there any way to run my Jenkins slave automatically.I have configured slave and the Launch method is launch slave agents via java web start.Don't know how to resolve the issue.Could any one please help me out on this? My Jenkins version is 1.585.

Related

Can Jenkins Slave machine be configured for two different servers

Hello At work we have 2 Jenkins servers but at the moment we have limited slaves machines , I was asked to make a research if its possible to configure a slave machine for 2 different servers ?
so if I would use a machine as a slave I would do these steps:
1-Install Jenkins on the slave machine.
2-On the Jenkins master, go to "Manage Jenkins" and then click on "Manage Nodes".
3-Click on "New Node" to create a new slave node.
4-Give your slave node a name and select "Permanent Agent" as the type.
5-Click "OK" to create the slave node.
6-On the slave machine, open a terminal and navigate to the Jenkins home directory. This is typically located at /var/lib/jenkins on Linux machines.
7-java -jar slave.jar -jnlpUrl https://<Jenkins_URL>/computer/<Node_Name>/slave-agent.jnlp -secret <Node_Secret>
Replace <Jenkins_URL> with the URL of your Jenkins server, <Node_Name> with the name of your slave node, and <Node_Secret> with the secret that was generated for the slave node on the Jenkins master.
8-The slave agent should now be connected to the Jenkins master and ready to run build tasks.
why can't I do the same steps twice for two different servers , can you explain why it's not possible ?
It is possible but you have to configure them differently.
Both applications are same so windows/java by default thinks it as reconnection instead of new instance. Not sure but this can work by renaming your jnlp files.
Both the application needs to configure to use different IP to avoid connection error.

Why Jenkins Slave need java to run slave.jar?

Via SSH slave plugin, we can have Jenkins slave to run specific job, but in my understanding, only SSH is enough to execute commands, why Jenkins still want to run slave.jar(Have to install JAVA)?
SSH is the communication mechanism between the master and slave machines.
The slave still has to run something to listen to the master and to do the actual builds. That Jenkins slave code is written in Java and stored in slave.jar.
So the reason you need Java on the slave machine is because the Jenkins slave software is written in Java. SSH is used by the master to tell the slave to do something.

How to allow slaves to connect to jenkins master without "-secret" jnlp option?

Yesterday, my jenkins master (v 1.646, linux debian Jessie 8.3) was working and several slaves was connecting on it via the jnlp command:
java -jar slave.jar -jnlpUrl http://myhost:8080/computer/bob-pc.local/slave-agent.jnlp
Now I guess something changed (war update ? plugin update ? security option changed ?) because now my slaves cant connect anymore since the jnlp command is now :
java -jar slave.jar -jnlpUrl http://myhost:8080/computer/bob-pc.local/slave-agent.jnlp -secret rt435te435a208c7201d99f7b1e5dd9c044da86d12efd8527
The -secret ... part of the command is new and I cant figure out which change added this option.
How to allow slaves to connect to jenkins master without "-secret" jnlp option ?
This credential behavior is controlled by Matrix Authorization Strategy Plugin, this plugin is shipped with jenkins by default.
If you are the jenkins administrator, you can turn this off by following these steps:
Manage Jenkins -->Configure Global Security-->Access Control-->Authorization
Either in Matrix-based security or Project-based Matrix Authorization Strategy, make sure you you have checked the Connect options of Slave for Anonymous role.

In jenkins not able to connect to slave

In master- slave the after running the jar for the slave from command prompt it is displaying connected but in the Jenkins it is displaying not getting connected to the slave The jenkins is deployed on linux server and trying to connect to slave from windows server by running slave jar
Manage Jenkins > Manage Nodes > See listed nodes and click on the slave name. You should be able to Launch agent from browser on slave.
If an error occurs, paste the error message here.

Jenkins build slave appears offline but slave service is up and Running

I am having trouble that Jenkins home page shows the Build slave is offline. But when I actually log in to build slave server, the slave service is up and running.
I am using Windows 2003 OS for all my Build slaves and Master server. The only way to get it online is to restart the service again.
Follow the given steps, you will not required to restart the services.
Goto Jenkins -> Manage Jenkins -> Manage Nodes
This will show you the list configured nodes.
In which
Build Slave -> Launch Slave Agent (Where "Build Slave" is your slave node.)
This will work if your slave is configured properly and connected with the services.
Jenkins master need communicate with Slave with ssh connection if master and slave are not in the same node.
Double check if master's ssh public key is in slave's ~/.ssh/authorized_keys.

Resources