MRalwasser
MRalwasser

Reputation: 15953

Jenkins: Throttle build rate

Using Jenkins, is it possible to limit job execution to run only once within a given interval?

E.g. I need to configure an expensive job which should be executed no more than 2 times per hour.

Note:
I was not able to get this working using the quiet period feature, because its timer will be reset once another build trigger occurs within the quiet period interval.
If such build trigger occur more often than the quiet period lasts, builds will never be made.

Upvotes: 2

Views: 4078

Answers (2)

Amol Manthalkar
Amol Manthalkar

Reputation: 2088

If you want to run the job not more than 2 times in an hour then you can use Poll SCM trigger and set cron as H/30 * * * *. This performs scheduled check every 30 minutes.
Note - The build is not triggered if there are no changes in this 30 minutes.

Upvotes: 0

Slav
Slav

Reputation: 27485

You can always just schedule a build to be in twice-per-hour intervals. And once it triggers, manually check if there are SCM changes. If not, abort.

Edit:
Assumptions:

  • This job is some kind of test-execution job, which itself doesn't depend on SCM changes (but it can update SCM as part of the job).
  • This job does not receive any special run parameters from upstream, else what do you plan to do about 2 different invocations within the desired time period.

You may consider Build Result Trigger plugin. Configure the "upstream job" as the job to monitor (do not configure downstream from the upstream job). Configure the cron tab to run every 30 minutes 0,30 * * * *

Upvotes: 2

Related Questions