It's all about the answers!

Ask a question

Trying to disable BuildSchedule using setScheduleEnabled

Kelly Anakwe (6198) | asked Nov 10 '10, 11:40 a.m.

I'm writing some code to programmatically disable a build definition schedule I had set up earlier and am not ables to use the method to do this.

The code chunk that carries out the action is below:

public IBuildDefinition disableBuildSchedule(ITeamRepository repo) throws Exception
IProgressMonitor monitor = new NullProgressMonitor();

// code for getting specific RTC build definition
ITeamBuildClient teamBuildClient = (ITeamBuildClient) repo.getClientLibrary(ITeamBuildClient.class);
IBuildDefinition definition= teamBuildClient.getBuildDefinition(buildDefName,monitor);

if (definition != null) {

// START : set build schedule
IBuildSchedule schedule = definition.getBuildSchedule();
if ( schedule != null){
System.out.println("Schedule enabled? "+schedule.isScheduleEnabled());
else {
System.out.println("Unable to extract schedule");
// END : set build schedule
I get into the schedule != null code and can print out Schedule enabled? true. However when I add the line to disable the schedule, schedule.setScheduleEnabled(false);
and run the code again, I get an ImmutableProperty Exception
at org.eclipse.emf.common.notify.impl.BasicNotifierImpl.eNotify(
at DisableRTCBuildSchedule.disableBuildSchedule(
at DisableRTCBuildSchedule.main(

has anyone got any ideas on how I can use this mthod (or any others) to diable the schedule.


2 answers

permanent link
Nick Edgar (6.5k711) | answered Nov 10 '10, 11:58 a.m.
Hi Kelly.

Before making modifications to an item, you need to get a working copy of it. Then, when done, you need to save the working copy. This is a general pattern throughout the Jazz/RTC API (both client and server).


ITeamBuildClient teamBuildClient = (ITeamBuildClient) repo.getClientLibrary(ITeamBuildClient.class);
IBuildDefinition definition= teamBuildClient.getBuildDefinition(buildDefName, monitor);
definition = (IBuildDefinition) definition.getWorkingCopy();
IBuildSchedule schedule = definition.getBuildSchedule();
definition =, monitor);

Note that we're getting a working copy of the definition here, and saving that, not the schedule. That's because the schedule is a helper within the definition, not a separately stored item. IBuildDefinition inherits from IItem, but IBuildSchedule does not.

permanent link
Kelly Anakwe (6198) | answered Nov 10 '10, 2:45 p.m.
Thanks Nick, that has worked perfectly for me

Your answer

Register or to post your answer.