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.

set configuration general setting options through script #3854

HealingQuickly ·

Hello Robin

I am trying to set a configuration's general settings through Groovy. General settings such as build condition and build schedule. I've found the "configuration" class doc in 7.0.28 release Javadoc. And there are indeed the function

public void setBuildCondition(BuildCondition buildCondition)

public void setSchedule(Schedule schedule)

I looked into the class "Schedule" and "BuildCondition", and still have no idea how to use them.
There isn't an example for the functions. And I'm not sure if I need to use some kind of "manager" class to create such arguments to pass it in or to put these operations in session.


Anyway, I'm trying to disable the build schedule for a template configuration, and I only copy that template as new when needed, and I would like the newly created "real" configuration to be able to build by schedule (by setting the build schedule or build condition via Groovy. I figure we can just disable either the schedule or build condition, not have to be both).

The condition is detect repo changes, and schedule is based on periodic schedule.

Could you show me how this is done?

Thank you very much!

  • solved #2
  • replies 5
  • views 2566
  • stars 0
robinshen ADMIN ·

Schedule and BuildCondition has a number of implementations, for instance:

groovy:

import com.pmease.quickbuild.taskschedule.schedule.*;
import com.pmease.quickbuild.setting.configuration.buildcondition.*;
def schedule = new PeriodicalSchedule();
schedule.repeatInterval = "30"; // 30 seconds
def buildCondition = new BuildIfChanged();
copiedConf.setSchedule(schedule);
copiedConf.setBuildCondition(buildCondition);
system.configurationManager.save(copiedConf);
HealingQuickly ·

Thank you for the reply.

I couldn't find the fields of a Schedule or PeriodicalSchedule class. I'm guessing there is another field "randomRange"? Like "repeatInterval"?

Thank you!

robinshen ADMIN ·

Yes it is randomRange. Forget to document this field.

HealingQuickly ·

After I set the PeriodicalSchedule (schedule here) to schedule.repeatInterval = "30", I set schedule.randomRange = "0", and the GUI shows the random range is 48; and I set the randomRange = "5", the GUI shows the it becomes 48 + 5 (53). So I just left it default, which is not 0 but 60. How does this work?

Thanks!

robinshen ADMIN ·

randomRange expects int instead of string.