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.
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?
- 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.