Set build schedule
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
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