It's all about the answers!

Ask a question

Set build schedule


SUNIL KUURAM (6431923) | asked Nov 13 '14, 4:13 p.m.
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.

 IBuildDefinition definition = ...

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



permanent link
Nick Edgar (6.5k711) | answered Nov 24 '14, 11:25 a.m.
JAZZ DEVELOPER
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
Nick Edgar commented Nov 24 '14, 11:29 a.m.
JAZZ DEVELOPER

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).


SUNIL KUURAM commented Feb 10 '15, 2:09 p.m.

This worked. Many Thanks Nick!


Nick Edgar commented Feb 10 '15, 3:45 p.m.
JAZZ DEVELOPER

Good to hear, Sunil. Could you please mark my answer as accepted, so this topic can get cleared from our tracking dashboards?

Your answer


Register or to post your answer.


Dashboards and work items are no longer publicly available, so some links may be invalid. We now provide similar information through other means. Learn more here.