We are using webhooks to trigger a Jenkins jobs when merge request created in Gitlab project. If any interruption occurs when a Jenkins job is running, should abort the job.
Consider the following cases too to abort the Jenkins job.
Slave disconnected from Jenkins master machine
Jenkins server restarted
Is there any plugin available to abort the job on interruption?
When a slave is disconnected from server , build will fail as no executor will be available for the job to continue further , possible error will "NO JDK found "
When jenkins is restarted it will stop all jobs in execution and queue.
AFAIK there is no perfect matched plugin for your requirement , reason being Java only allows threads to be interrupted at a set of fixed locations, depending on how a build hangs, the abort operation might not take effect.
But you can try some rest api's https://wiki.jenkins.io/display/JENKINS/Aborting+a+build
Or abort a job on some conditions :
https://wiki.jenkins.io/display/JENKINS/Build-timeout+Plugin
Some more ref :
How to stop an unstoppable zombie job on Jenkins without restarting the server?
Related
I want to upgrade my jenkins master without aborting or waiting for long running jobs to finish on slaves. Is there a plugin available that provides this feature?
We have several build jobs running regression and integration tests which take hours to run. Often, at least one of those jobs is running, making it hard to restart jenkins after updates. I know, that it is poosible to block the queue. We tried this, but it hinders more than it helps.
What we are looking for is a plugin, that runs jobs on slaves, caches the output as soon as the connection to the master is interrupted and sends the remaining output to the master when the master is up again. Does anybody know a plugin providing this feature.
I am running a Jenkins server on DCOS as documented here https://docs.mesosphere.com/1.7/usage/tutorials/jenkins/.
The Jenkins server is able to spawn new mesos slaves when new jobs are scheduled and kill them when the job is completed.
But if a cluster node crashes, having a Jenkins job running on it, Jenkins server doesn't re-run the job on other available nodes.
Is the Jenkins service on DCOS fault tolerant?
Can we re-run the job(on some other available node) that failed due to cluster node crashed in between execution of the job?
Jenkins itself does not rerun jobs that disappear. It is not specific to DC/OS or Mesos, it's just the way Jenkins works.
DC/OS and Mesos will make sure that Jenkins stays running and available to send jobs to, and in this way, it is "fault tolerant", but in the way you are asking about it isn't.
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 configured Jenkins Slave and created a job to run in slave.
After triggering the job , if I am stopping it in Jenkins it showing the Job has been stopped.
But in the node still script is still running.
I noticed that too. see also JENKINS-6188
we have jenkins project. use case:
jenkins triggers the build
slave agent builds application
server with slave agent goes to reboot (for any reason, for example, problem with electricity, somebody rebooted it, resource shortage and so on)
after that jenkins reports about failed build. how can we automatically relaunch application building in jenkins when slave agent recovered from failure?
There are two aspects to this issue -
Jenkins Server needs to reschedule the build that failed(when the slave-machine crashed).
Install the Naginator Plugin
Set it to rebuild whatever job you have set on the problematic slave
Jenkins Slave needs to restart automatically as soon as its host is up again.
On Windows, for example, you need to set it with a service that starts automatically
Note the Naginator Plugin doesn't know what caused the build to fail,
so it will try to rebuild any build that fails.
To solve this, scan the log for an indication that the slave crashed
and set a regular expression (in the Naginator) to catch it.
Cheers