Cron jobs on build agents as Jenkins Jobs

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Cron jobs on build agents as Jenkins Jobs

Ian Vernon
Hi!
I want to have jobs that run at a specified cadence (say every 2 hours). I know that this is possible via cron syntax, and have this setup for a variety of jobs. However, I have somewhat specific requirements. I've looked around to try to figure out how to do this, but I've been coming up dry. Is there a way for me to be able to have the following requirements for a scheduled, reoccurring job? :

* Do not allow any other builds to be scheduled on the Jenkins agent / node even though an agent has multiple executors. For example, two builds finish up on one agent, and then my Jenkins job runs. No other build / job runs on the agent despite there being only one executor used, because my cron job dictates that it can be the only job running on the agent at that time.
* Make sure that the job runs on all available Jenkins agents. I.e., if I have four agents, I want to make sure it is scheduled to run on each node at a two hour cadence. 

Thanks!

--
You received this message because you are subscribed to the Google Groups "Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/f8062284-1d09-4974-a787-e1d124e8e1db%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Cron jobs on build agents as Jenkins Jobs

Victor Martinez
Off the top of my head what if you use: https://plugins.jenkins.io/heavy-job then you can allocate a specific weight which its size is greater than half of the number of executors of those agents? 

For instance:
- agent_a => number of executors 4
- agent_b => number of executors 4

- job_1 => weight = 3
- job_2 => weight = 3

This will work only if those agents are based on the same number of executors.

Besides of that, you might need to use the matrix project https://wiki.jenkins.io/display/JENKINS/Matrix+Project+Plugin to accomplish your second requirement.

There are other ways by using the https://plugins.jenkins.io/lockable-resources but then you need to specify those critical sections using the resources. If you use pipelines, then probably this is the way to go.

My two cents

--
You received this message because you are subscribed to the Google Groups "Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/5a2304bc-8278-4d8c-9735-3a81ee72a129%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.