Jenkins: Throttle build rate

萝らか妹 提交于 2020-01-25 00:30:34

问题


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.


回答1:


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 * * * *




回答2:


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.



来源:https://stackoverflow.com/questions/29605954/jenkins-throttle-build-rate

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!