I am using digital ocean droplet.My scenarios is: I have Jenkins installed on my one server, in which I have configured the job.I want to run that job on to another server.How to achieve that?(How my Jenkins will able to ssh to another server)
If you want to execute a single command on another server - use ssh to invoke command as a build step.
If you want to run a complex job - you should configure target server as a slave and point your job to run on a specific node(slave).
Configuring slave is pretty easy, take a look at the following articles
https://wiki.jenkins.io/display/JENKINS/Distributed+builds
https://wiki.jenkins.io/display/JENKINS/SSH+Slaves+plugin
Related
I have multiple Unix servers where I need to stop and start few services (name of the service are same in all servers and login user and password is also same). I am able to restart services for single unix server using Execute shell script on remote host using ssh. But not able to do for multiple servers.
Ex: Server 1 and server 2 (Both are unix servers)
script file name: sample.sh
order to run this script using Jenkins:
stop service in Server1 using sample.sh script
stop service in Server2 using sample.sh script
start service in Server1 using sample.sh script
start service in Server2 using sample.sh script
please let me know how to achieve this using Jenkins. I have done this by creating 4 job for 4 steps and then pipelined them. But in real time i have more than 10 servers and i believe this is not a good way to do.
I think your best approach would be using the Matrix Project plugin. We use it to run adminstration tasks on all nodes matching a given label in parallel.
Trivally, you can use one matrix job to stop service on all nodes and when done, trigger 2nd job to start all nodes.
It has lots of extension points defined as well.
From the notes;
You have to choose "Build multi-configuration project" when
creating a project, it can not be changed later. If you skip this
step, you will be very confused and not get very far
Each configuration is akin to an individual job. It has its own build history, logs, environment, etc. The history of your
multi-config job only shows you a list of configurations executed. You
have to drill into each configuration to see the history and console
logs.
We got a requirement to implement CICD using Jenkins.
Here, Jenkins is running in windows machine and application server running in linux machine and build activity should happen in Linux system. So, We are connecting to linux machine using Jenkins's SSH plugin and executing jobs.
I have created list of freestyle jobs to checkout code from CVS, cleanup activity, Build , stop server, start server, Run Junit, run sonar. all these jobs are chained using 'build other projects' option in post build Action section.
Here, all jobs executes in sequential manner. But, sometimes I need to execute only few jobs like stop and start server.
So, please help me how we can randomly pick jobs which need to be run before triggering build.
Thanks,
Ganesha
I would like to set up jenkins server that would run test scripts based on successful build deployments on other Jenkins servers. for example, if the QA jenkins server is named JQA1OnMachine1 and i have three others that are named
J2OnMachine2, J3OnMachine3, J4OnMachine4 (different jenkins server on different boxes) can the JQA1OnMachine1 (QA jenkis) poll the others at regular interval to see if a build was deployed successfully? if so can anyone tell me how?
Jenkins master slave along with Jenkins Pipeline Plugin would be one of the better ways to implement this however, since you don't want to use that approach you can explore PSTools to remotely capture processes or files on different server.
Your builds may update a file on the build server post completion of the build and your QA machine can run script with PSTools to monitor and trigger the QA testing based on the file content
I'm new to Jenkins, and I like to know if it is possible to have one Jenkins server to deploy / update code on multiple web servers.
Currently, I have two web servers, which are using python Fabric for deployment.
Any good tutorials, will be greatly welcomed.
One solution could be to declare your web servers as slave nodes.
First thing, give jenkins credentials to your servers (login/password or ssh login+private key or certificate. This can be configured in the "Manage credentials" menu
Then configure the slave nodes. Read the doc
Then, create a multi-configuration job. First you have to install the matrix-project plugin. This will allow you to send the same deployment intructions to both your servers at once
Since you are already using Fabic for deployment, I would suggest installing Fabric on the Jenkins master and have Jenkins kick off the Fabric commands to deploy to the remote servers. You could set up the hostnames or IPs of the remote servers as parameters to the build and just have shell commands that iterate over them and run the Fabric commands. You can take this a step further and have the same job deploy to dev/test/prod just by using a different set of hosts.
I would not make the webservers slave nodes. Reserve slave nodes for build jobs. For example, if you need to build a windows application, you will need a windows Jenkins slave. IF you have a problem with installing Fabric on your Jenkins master, you could create a slave node that is responsible for running Fabric deploys and force anything that runs a fabric command to use that slave. I feel like this is overly complex but if you have a ton of builds on your master, you might want to go this route.
I want to configure Jenkins to build my code on 1 server. Then want to deploy it on another server using Jenkins.Both servers are using Linux I want to automate the entire process as much as possible. I went through some of plugins like pipeline, Job Import Plugin, etc
Can anyone guide me how to go about it ? Which plugins will be useful ? Any example or tutorial somewhere will be useful. The configuration of build pipeline plugin on jenkins was not seamless for me.
Thanks,
Bhargav
I would work it this way :
Install jenkins on your first server
Install the following plugins : ssh credentials, ssh slaves, copy to
slave, and restart jenkins
Go to Manage jenkins -> Manage credentials, and add ssh credentials
for your second server
Go to Manage jenkins -> Manage nodes, and create a passive slave.
The launch method should be "Launch slave agents on Unix machines
via ssh". You should use the credentials that you have added in step
3
Create a job to build your code. In the advanded options of job, you
should indicate that the job must only be built on master node.
Create a job to deploy your code on the second server. In the
avanded options of job, you should indicate that the job must only
be built on slave node.
In the "Build Environment" section, check the "Copy files into workspace before building" box and configure what files you want to copy from first server (https://wiki.jenkins-ci.org/display/JENKINS/Copy+To+Slave+Plugin)
The code will be copied into the jenkins slave's workspace.