I have logged-in to Jenkins UI using my Unix credentials (pmandal).
Then I have added a slave node (Slave1).
Now when i "Launch slave", it tries to ssh from the MASTER to the Slave(Slave1) as "jenkins" USER, and ssh fails.
My requirement is: I want the ssh from the MASTER to the Slave as a different user say "UserZ", coz i want all my operations to be performed as UserZ.
But i am unable to do so.
So my main question here is : "How to i make the MASTER to ssh to the Slave as UserZ"?
Any help would be appreciated.jenk
create the credentials in jenkins store.
This can be done from https://<yourjenkins.url>/credentials/store/system/domain/_/newCredentials
connect the node with the option "launch agent agents via ssh jenkins". From the config page of the node, you can select the credentials you just created
Note: the option "launch agent agents via ssh jenkins" is the recommended way to connect unix/linux machines: https://support.cloudbees.com/hc/en-us/articles/115003929412-How-to-create-an-agent-in-Linux-from-console
Related
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.
I have installed a Jenkins master on my Mac OS, version is 2.90.
I have installed a Jenkins slave on my ubuntu, and created a user called jenkins at /home/jenkins.
I have copied my pub key from master to slave and using
ssh jenkins#slave_ip
I can login from master to slave with no password.
However, I cannot create a new slave at Jenkins, it has the following issues:
1. Launch method does not have option "Launch slave agents via SSH",therefore I cannot set credentials.
2. since launch method only has "Launch agent via execution of command on the master" and another option for windows, I input Launch command as: ssh -v jenkins#slave_ip.
but master cannot connect with slave.
To troubleshoot, I login slave manually, I see master does ssh to slave successfully. as it shows:
sudo tail -f /var/log/auth.log:
Nov 19 00:10:32 ip-172-31-18-180 sshd[8908]: Accepted publickey for
jenkins from my_master_ip port 62411 ssh2: RSA
80:23:0e:1b:34:c1:90:52:a6:df:d0:24:6f:10:80:73
Nov 19 00:10:32 ip-172-31-18-180 sshd[8908]: pam_unix(sshd:session):
session opened for user jenkins by (uid=0)
so I doubt maybe Jenkins credential is not set because master does not send private key to slave. (I do not have this option in my Jenkins UI)
what should I do? how to make Launch method option "Launch slave agents via SSH" show, so that I can input credential of master?
you should use Launch slave agents via SSH to connect the ubuntu as slave.
you should install https://wiki.jenkins.io/display/JENKINS/SSH+Slaves+plugin
than add the Host & Credentials
Is there any way to find the IP/hostname of the slave node?
Situation here is,
no access to the Jenkins master machine.
no details to the Slave Machine available.
Just we have is to login Jenkins Master dashboard and can see the slaves.
I couldn't able to fins any details of the slaves IP or Hostname.
Your steps to find or suggestions will be appreciated.
This is not same as the below case
How to find the ip address of a jenkins node from the master
I cannot able to login to the Jenkins master machine too.
I have found the easiest way to find the node/slave machines IP from Jenkins Master UI.
Goto Jenkins Master Dashboard page
Click Manage Jenkins
Click Manage Nodes
Click Any Slave Machine
Click Log
You can see the first line with the IP Address of it.
The way to get the slave machine Host name is as below,
Manage Jenkins -> Manage Nodes -> (Select the Slave Machine ) -> System Properties
Then Look for "Computer Name"
I have a simple Jenkins master/slave set-up but I'd like to be able to switch which master the slave points at.
Is it possible to do this by changing some config on the slave?
For a Windows Slave configuration remove the JNLP Slave for Master1/Slave node by
1. Stopping the Jenkins Slave Windows service
2. Launch a Command Prompt as an Administrator
3. then use sc delete jenkins_service_name
For OS X check out https://github.com/rhwood/jenkins-slave-osx/wiki/Uninstall
Now open a browser on the slave machine and go to your Jenkins master2 server url then Jenkins -> Manage Jenkins -> Manage Nodes -> Node (assuming the node is already setup on master2 server) and click on the Launch button to launch agent from browser on slave machine. You prob. know how to do this already. If not use this guide https://wiki.jenkins-ci.org/display/JENKINS/Step+by+step+guide+to+set+up+master+and+slave+machines
Maybe you can try having the slave setup on both master1 and master2 by
1. Skip my delete steps above
2. open a browser on the slave machine and go to your Jenkins master2 server url then Jenkins -> Manage Jenkins -> Manage Nodes -> Node (assuming the node is already setup on master2 server) and click on the Launch button to launch agent from browser on slave machine.
3. Instead do "Save File" and click ok in step 5b from https://wiki.jenkins-ci.org/display/JENKINS/Step+by+step+guide+to+set+up+master+and+slave+machines
4. Save the slave-agent.jnlp to a new folder. I'm sure the two agents will run on that slave machine without interfering each other.
Definitely. If you want to be able to switch the slave back and forth between two masters, you can set up a second slave agent on the slave machine. Steps to do this depend on the type of slave (JNLP, remote ssh, etc). Disconnect the slave from the old master using the Manage Slaves page, and shut down the first slave agent on the slave machine. Start your second slave agent, and add that slave to the second master.
You can actually have both slave agents running and have the slave be connected to both masters, although they won't know anything about each other and could both send a job to the slave at the same time regardless of the number of executors.
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.