I am just starting with Jenkins, and I am confused on the Remote root directory, the WorkDir and the Internal data directory, precisely on their full path, including Hostname.
The slave is supposed to be on a different node, but I don't see where we can specify a Hostname or IP address.
The examples Remote root directory I have seen so far looks like /var/jenkins, is it on the master node ? if not how or where do we specify the remote Hostname or IP address ?
Same for the Workir, is it remote or local ?
Thanks in advance.
Your jenkins master node can run builds and works as an slave too.
Remote root directory is on the slave.
Manage the slaves is in section "Manage Nodes".
Specify the hostname/IP Address in the launch method option: "via SSH"
To join a slave:
https://medium.com/#chathurams.sa/step-by-step-guide-to-add-jenkins-slave-nodes-f2e756c8849e
Related
In our setup, Docker container are working as Jenkins node/agents. This is done via adding docker host through "Configure cloud". Now we have to carry out some household activity on these Docker hosts. But before that I want No jenkins job should use that docker host during the activity. Is there any option to do so?
I was thinking to mark agent as offline. BUt in this case, I cannot find this option.
Please help.
I have a ec2 instance running as my jenkins master. I would like to run a container in that instance that will be used as another build executor so I can tun a few builds simultaneously.
Im having pronblems connecting these.
In the docker hub jenkins docs it says under the relevant section:
You can run builds on the master out of the box.
But if you want to attach build slave servers through JNLP (Java Web
Start): make sure you map the port: -p 50000:50000 - which will be
used when you connect a slave agent.
If you are only using SSH slaves, then you do NOT need to put that
port mapping.
but when I try to add a node in the jenkins config, it asks remote root directory (probably should be /var/jenkins ? ) and a launch method.
I don't quite understand what I should give it as its launch method to make this work and I don't understand where the port number comes into play.
What you need is Jenkins Docker plugin (link below) and follow the instructions listed here
https://wiki.jenkins.io/display/JENKINS/Docker+Plugin
I followed those instructions and was able to setup dynamic slaves in Jenkins which are dynamically provisioned.
I run docker container with Jenkins master. I run docker container with Jenkins slave (slave image) and exposed port 8082:8080.
I created docker network to make containers see each other and it works (ping works).
I installed Docker Plugin on Jenkins master. I checked IP address of the slave container and tried to use it in the master's configuration, but master cannot connect to slave:
I think I'm doing something wrong. Any ideas what else should I do?
First check your docker daemon listening on your DockerURL and then try Testconnection
sudo dockerd
check API listening on
or provide your certs path to credential section.
certs path usually will be %userprofile%/.docker
It is throwing HttpHostConnectException because you are using tcp in the Docker URL field. Use http. Check the configuration document here.
I solved my problem.
Here is nice tutorial about setting up master in docker container and slaves aslo in docker containers. It doesn't use Docker Plugin.
I would like to get the swarm manager node name or ip address from an host that is not part of the swarm.
The host is Jenkins and I have SSH keys configured to get access to every machine in the swarm, but to create a service I need to run the command on the manager.
What approach is the best to get one of the active swarm manager name or address?
I think when You hardcode the ip address it would be the least flexible way. Hostname, assume you have your dns setup working, will give you the flexibility to change the underlaying ip via dns records not modifying your jenkins jobs.
I'm in similar situation, but I wanted the solution without ssh-ing to the manager host. Looks like current docker pipeline does not support swarm mode at all.
I have a Jenkins and Kubernetes cluster running within the same network in AWS. Jenkins has it's own instance.
I have configured the Kubernetes plugin as follows:
The recommended JNLP docker image is used. Jenkins JNLP port is configured to be static 5000.
Now when I kick off the job, it shows me that the node is offline. When I click on the offline node I get this:
This makes me go to the k8 cluster. Running docker ps shows no containers running. However:
From there I go to find what docker container gets run and what logs it leaves after that:
I use:
https://github.com/jenkinsci/docker-jnlp-slave as image
https://github.com/jenkinsci/kubernetes-plugin
Jenkins version: 2.27
k8: hyperkube:v1.4.3_coreos.0
Jenkins does spin up the container, I guess it runs and errors out because no valid arguments are provided during the container run? I need it to be a hands off process where I don't have to log in to my containers (Java clients). How do I achieve this?
UPDATE
Based on this answer: kubernetes slaves cannot register to jenkins master
If I log into the container and run the command that Jenkins displays under the host that cannot connect:
java -jar /usr/share/jenkins/slave.jar -jnlpUrl https://test.myhost.com/computer/jenkinsminions-10f0b7d49054ac/slave-agent.jnlp -secret 62637e83008f50eb94483ad609e9a2719d313fa56e640e4beca9eebeaf0b1af2
The container connects via JNLP2 and the job runs.
I tried to add the arguments as suggested, but no luck. Containers still won't connect automatically:
Do you have a Root directory not writable message in the container log?
[...]
Exception in thread "main" java.lang.RuntimeException: Root directory not writable
at hudson.remoting.FileSystemJarCache.<init>(FileSystemJarCache.java:44)
at hudson.remoting.Engine.<init>(Engine.java:139)
at hudson.remoting.jnlp.Main.createEngine(Main.java:164)
at hudson.remoting.jnlp.Main.main(Main.java:148)
at hudson.remoting.jnlp.Main._main(Main.java:144)
at hudson.remoting.jnlp.Main.main(Main.java:110)
In this case, you might have a problem similar to this.
PS: If you cannot see the logs, try removing the "Allocate pseudotty" option