Jenkins - Build Steps - jenkins

I am currently writing a Jenkins job to connect to different sql servers to check if all the application servers are up and running.
What I want to achieve:
Connect to QA SQL Server, run the query to verify server status.
Parse the Jenkins log and If any of the servers is down, send a mail to destination1#abc.com with the server name and server id.
Connect to Parallel SQL Server, run the query to verify server status.
Parse the Jenkins log and If any of the servers is down, send a mail to destination2#abc.com with the server name and server id.
Challenge I am facing:
I have used 2 build steps (Windows batch command) i.e. one for parallel and one for QA. But, if the first one fails, Jenkins doesn't execute the second one.
Can someone please suggest how this can be achieved?

The classic solution would be to write the second build step as a Post-Build step, using the JENKINS Post build task
That post build step would be executed even if the first build step fails.
But the more modern and logical solution would be to execute them in their own job, using the JENKINS Multijob Plugin, or even Jenkins pipelines, as shown in "Jobs in parallel".

Related

execute same command in multiple unix servers using Jenkins

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.

Jenkins skip some jobs in chain of freestyle jobs

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

How to run a Jenkins job in other servers?

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

Communicate between Jenkins server without setting up master slave relation

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

Can Jenkins detect when a new build is available on a Bamboo server?

Can Jenkins detect when a new build is available on a Bamboo server?
What I want is to create a Jenkins job that checks a Bamboo server for a new build. I want this job to run once per hour.
Then, other tests that I have on that Jenkins server will rely on that check passing in order for them to kick off.
If this is possible, what is the usual way of doing this? The Bamboo server is internal and does not need authentication to see status of builds or get build resources.
If there is no plugin for this, I do see a RSS feed at this URI: /rss/createAllBuildsRssFeed.action?feedType=rssAll&buildKey=RELEASE . What method would other Jenkins administrators use to read this feed?
I figured out the answer myself. I wrote a Gradle unit test to run in Jenkins that can read the RSS feed in Bamboo.
The real way to do it though, which didn't answer my question, is to add a post-build hook to either Subverison or Bamboo to send a HTTP get request to Jenkins, which notifies a job to run.

Resources