Set build schedule
![](http://jazz.net/_images/myphoto/fda6289a60fe8c54ba9e7aaf335c4aae.jpg)
I have tried below to turn off/on the build schedule on a build definition. I'm getting an error that the method property is immutable. Error description below. I'm using RTC 4.0.5 Please advise.
IBuildSchedule schedule = definition.getBuildSchedule();
schedule.setScheduleEnabled(true);
schedule.setBuildOnMonday(true);
schedule.setBuildInterval(30); // every 30 minutes
Exception in thread "main" com.ibm.team.repository.common.internal.ImmutablePropertyException
at com.ibm.team.repository.common.internal.util.ItemUtil$ProtectAdapter.notifyChanged(ItemUtil.java:2001)
at org.eclipse.emf.common.notify.impl.BasicNotifierImpl.eNotify(BasicNotifierImpl.java:280)
at com.ibm.team.build.internal.common.model.impl.BuildScheduleImpl.setScheduleEnabled(BuildScheduleImpl.java:1073)
at SetSchedule.main(SetSchedule.java:130)
Regards
Sunil
One answer
![](http://jazz.net/_images/myphoto/fda6289a60fe8c54ba9e7aaf335c4aae.jpg)
Hi Sunil, my apologies for the delay on responding. The normal pattern for modifying an item is:
- read it from the repo (e.g. using IItemManager.fetch*)
- create a working copy (using IItem.getWorkingCopy()), casting back down to the specific item interface type
- make the changes
- save the item (the API for this differs depending on the item type, but for Build items it's usually ITeamBuildClient.save)
The error here looks like you're missing the getWorkingCopy step.
Cheers,
Nick
Comments
![](http://jazz.net/_images/myphoto/54af553052ca68179ee42f4d2bb409aa.jpg)
The item here is the build definition, not its schedule (which is a 'helper' under the main build definition item, not separately stored). So you should have a line before the sets like:
definition = (IBuildDefinition) definition.getWorkingCopy()
Then at the end save with:
definition = ClientFactory.getBuildClient().save(definition, progressMonitor)
Be sure to use the returned definition as the basis for any further changes, or it will complain that you're trying to base your changes off of a state that is no longer the current one (a StaleDataException is thrown in this case).
![](http://jazz.net/_images/myphoto/fda6289a60fe8c54ba9e7aaf335c4aae.jpg)
This worked. Many Thanks Nick!
![](http://jazz.net/_images/myphoto/54af553052ca68179ee42f4d2bb409aa.jpg)
Good to hear, Sunil. Could you please mark my answer as accepted, so this topic can get cleared from our tracking dashboards?