I'm trying to setup a Jenkins server to monitor a bunch of cron jobs. I will launch most of them using the Jenkins freestyle project however some of the cron jobs will be remote so they will be communicating back as external jobs. How can I get warnings when those external jobs fail? and can I set the schedule they should be on so I can get warnings even when they don't run?
Thanks.
To my understanding and to answer your latter question, you can setup an overall cron scheduler in your Jenkins monitoring job in such a way it runs exactly during the time you expect the remote cron to execute . Say ur remote job executes at 1 pm every day u can configure your Jenkins monitor cron to kick off a build at 12.45 pm or 1 pm based on ur needs.
A solution to your first question could be to have a wrapper script execute the remote invocation of jobs so tht u can monitor the return value of tht remote invocation.
Like if you have an ant script invoke the Java command remotely, it will return a non zero if the Java command failed execution and the ant script will also fail and so your Jenkins job executing the ant script will fail and u will be notified about it.
I can help you with further specific steps if you did not follow me
Related
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
A way to stop Jenkins from executing a build over period of time, example: '5-7pm'
Example my session of Jenkins executes builds continuously, is there a way to stop a build from executing over a specific time period for example dont execute a build between 5-7pm?
If you build continuously, I guess you're using SCM polling (eg. poll the SCM every 2 minutes). If that's the case, just configure polling to exclude the desired time-frame. This is done using standard "cron" syntax (help and examples are available from the Jenkins UI).
I have a couple of unit testing / BDD jobs on our Jenkins instance that trigger a bunch of processes as they run. I have multiple Windows slaves, any one of which can run my tests.
After the text execution is complete, irrespective of the build status is passed/failed/unstable, I want to run "taskkill" and kill a couple of processes.
I had been doing that earlier by triggering a "Test_Janitor" downstream job - but this approach doesn't work anymore since I added more than one slave.
How can I either run the downstream job on the same slave as the upstream, or have some sort of a post build step to run "taskkill".
You can install the Post Build Task plugin to call a batch script on the slave (when your UT/BDD are completed).
The other solution is to call a downstream job and to pass the %NODE_NAME% variable to this job with the Parameterized Trigger plugin.
Next, you can use psexec to kill the processes on the relevant node.
I've got a Jenkins job that is intended to do the following:
Build a project and deploy it to a test server
Run tests
If the tests fail, roll back the server to the previous version
If the tests succeed, update the version in our source control system
Because we have a single test server, we need to ensure that Jenkins is only running a single version of this job at a time. Unfortunately, we can't seem to find a way to run a job on failure and keep the upstream job from executing while the downstream job is running.
Is there an easy way to do this? Is there a better way?
The Jenkins Post Build Task allows you to run tasks in a job after failure. Rolling the server back sounds more like a task than a job, so that might suit.
Otherwise, there are a couple of plugins that allow for more complex pipelining features. The Pipeline Plugin seems to be the most popular at the moment.
In job configuration, under Advanced Project Options (just before the SCM part), click the Advanced... button. You can now chose to Block build when upstream/downstream is executing
As for running conditional steps on failure:
- Use Post Build Tasks as Paul suggested, or
- Configure logic using Conditional Build steps
I have a Jenkins job which compiles and publishes our Java project to a JBoss server. Obviously, the server takes time to start and deploy the new code. I have a second Jenkins job that runs Selenium tests against the running JBoss instance.
I would like to make the second (Selenium) job be performed automatically as a post-build action from the first job (I have already done this), but I want it to be delayed by, say, 2 minutes. The amount of delay time isn't important, but I can't find anywhere that describes how to delay the start of a post-build job. How would I accomplish this?
In the advanced project options of a project configuration, you can set a "quiet period" that does exactly that. Jenkins will wait the specified amount of time after a build has been triggered before actually starting the build.
Alternatively, you could have the JBoss server trigger the build (e.g. by calling a URL) once it's up and running. The advantage of that is what it would take care of cases where the JBoss server doesn't start for some reason.
You might also want to have a look at the Parameterized Trigger Plugin which allows you to run builds of other projects as build steps. This way you could run the Selenium tests as part of the original job and fail if those tests fail.