[
https://issues.jenkins-ci.org/browse/JENKINS-12676?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Ignacio Albors reassigned JENKINS-12676:
----------------------------------------
Assignee: Ignacio Albors
> next-executions: Support evenly distributed crontab
> ---------------------------------------------------
>
> Key: JENKINS-12676
> URL: https://issues.jenkins-ci.org/browse/JENKINS-12676
> Project: Jenkins
> Issue Type: Bug
> Components: next-executions
> Environment: Next Executions 1.03
> Jenkins 1.450
> Reporter: OHTAKE Tomohiro
> Assignee: Ignacio Albors
> Priority: Minor
>
> Jenkins 1.448 added a new feature for crontab to distribute crontab evenly.
> See
> https://github.com/jenkinsci/jenkins/commit/b1bb3f66676b550971db08725d5c3cef5b42191b.
> The issue is that next execution plugin does not support the new feature.
> For instance, if a job is configured as crontab @daily,
> next executions plugin says that the next will be 09/02/2012 00:00.
> But actual next execution might be 09/02/2012 12:34 or 09/02/2012 01:23.
> An unsafe workaround is to read private fiels of Trigger and CronTabList.
> {code:title=NextExecutionsUtils.java}
> @@ -25,9 +27,23 @@ public static NextBuilds getNextBuild(AbstractProject
> project){
> if(!project.isDisabled()){
> Trigger trigger =
> project.getTrigger(TimerTrigger.class);
> if(trigger != null){
> - List<CronTab> crons =
> parseSpec(trigger.getSpec());
> + Vector<CronTab> tabs;
> + try {
> + Field fieldTriggerTabs =
> Trigger.class.getDeclaredField("tabs");
> + fieldTriggerTabs.setAccessible(true);
> + Field fieldCronTabListTabs =
> CronTabList.class.getDeclaredField("tabs");
> +
> fieldCronTabListTabs.setAccessible(true);
> + CronTabList crontablist =
> (CronTabList)fieldTriggerTabs.get(trigger);
> + tabs = (Vector<CronTab>)
> fieldCronTabListTabs.get(crontablist);
> + } catch (NoSuchFieldException ex) {
> + ex.printStackTrace();
> + throw new NoSuchFieldError();
> + } catch (IllegalAccessException ex) {
> + ex.printStackTrace();
> + throw new IllegalAccessError();
> + }
> Calendar cal = null;
> - for (CronTab cronTab : crons) {
> + for (CronTab cronTab : tabs) {
> Date d = new Date();
>
> cal = (cal == null ||
> cal.compareTo(cronTab.ceil(d.getTime())) > 0)? cronTab.ceil(d.getTime()) :
> cal;
> }
> {code}
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators:
https://issues.jenkins-ci.org/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira