Your browser was unable to load all of the resources. They may have been blocked by your firewall, proxy or browser configuration.
Press Ctrl+F5 or Ctrl+Shift+R to have your browser try again.

Directly set schedules via API? #4349

JShelton ·

Is it possible to directly set schedules for a config via Scripting API? I am wanting to use a configuration where an end-user can define a cron schedule and have that be set across several other configurations. Best way I have currently found involves using inheritance in an interesting way, something like the following:

In the "set schedule" config:

def someNewScheduleStr = "0/15 * * 1/1 * ? *"
vars.get('scheduleToInherit').setValue(someNewScheduleStr,true)

Since scheduleToInherit var is not overwritten in the "set schedule" config, passing in "true" as the boolean will set the variable further up the config tree. The configs with schedule changes, as children of the parent with the variable, then have this in the expression field when cron schedule is set:

${vars.getValue('scheduleToInherit')}

Is there a cleaner way to do this?

  • solved #2
  • replies 2
  • views 466
  • stars 0
robinshen ADMIN ·

Schedule can be set via below script. Set it to null if you want to inherit from parent:

groovy:
import com.pmease.quickbuild.taskschedule.schedule.*;

def schedule = new CronSchedule();
schedule.expression = "0 0 1 * * ?";
system.configurationManager.get("root/to/some/conf").setSchedule(schedule);
JShelton ·

Thank you! This works perfectly.