It's all about the answers!

Ask a question

Change workspace build property programatically


Luis Bazo (6832019) | asked Jun 19 '11, 2:51 p.m.
JAZZ DEVELOPER
Hi guys,

I was wondering to know if possible to change the build definition workspace programatically. As everything in my build definition for zOS is identical except an environment variable, target environment and the workspace to use.

I would like to execute (by RTC API) the build definitions from buildforge just by changing the workspace to use and one environment variable.

Is that possible?

I'm trying

buildDefinitionObj1.setConfigurationProperty("com.ibm.team.build.jazzscm","team.scm.WorkspaceUUID","_-cPrEJg1EeCIwcUNsKUI8Q");

but not sure if is going to work.

Thanks

4 answers



permanent link
Brent Ulbricht (2.5k11) | answered Jun 20 '11, 4:24 p.m.
JAZZ DEVELOPER
Hi guys,

I was wondering to know if possible to change the build definition workspace programatically. As everything in my build definition for zOS is identical except an environment variable, target environment and the workspace to use.

I would like to execute (by RTC API) the build definitions from buildforge just by changing the workspace to use and one environment variable.

Is that possible?

I'm trying

buildDefinitionObj1.setConfigurationProperty("com.ibm.team.build.jazzscm","team.scm.WorkspaceUUID","_-cPrEJg1EeCIwcUNsKUI8Q");

but not sure if is going to work.

Thanks


Hi,

This example code will change the workspace.


IProgressMonitor monitor = new NullProgressMonitor();
ITeamRepository teamRepository = login(repositoryURI, userId, password, monitor);

ITeamBuildClient buildClient = (ITeamBuildClient) teamRepository.getClientLibrary(ITeamBuildClient.class);
IBuildDefinition buildDefinition = buildClient.getBuildDefinition(buildDefinitionId, monitor);

IBuildDefinition workingDefinitionCopy = (IBuildDefinition) buildDefinition.getWorkingCopy();
workingDefinitionCopy.setProperty(IJazzScmConfigurationElement.PROPERTY_WORKSPACE_UUID, "_ZOldwI0VEeCBE-fD7bmXpg");
buildDefinition = buildClient.save(workingDefinitionCopy, new NullProgressMonitor());



Brent Ulbricht
RTC Build Lead

permanent link
Luis Bazo (6832019) | answered Jun 23 '11, 10:02 a.m.
JAZZ DEVELOPER
Hi guys,

I was wondering to know if possible to change the build definition workspace programatically. As everything in my build definition for zOS is identical except an environment variable, target environment and the workspace to use.

I would like to execute (by RTC API) the build definitions from buildforge just by changing the workspace to use and one environment variable.

Is that possible?

I'm trying

buildDefinitionObj1.setConfigurationProperty("com.ibm.team.build.jazzscm","team.scm.WorkspaceUUID","_-cPrEJg1EeCIwcUNsKUI8Q");

but not sure if is going to work.

Thanks


Hi,

This example code will change the workspace.


IProgressMonitor monitor = new NullProgressMonitor();
ITeamRepository teamRepository = login(repositoryURI, userId, password, monitor);

ITeamBuildClient buildClient = (ITeamBuildClient) teamRepository.getClientLibrary(ITeamBuildClient.class);
IBuildDefinition buildDefinition = buildClient.getBuildDefinition(buildDefinitionId, monitor);

IBuildDefinition workingDefinitionCopy = (IBuildDefinition) buildDefinition.getWorkingCopy();
workingDefinitionCopy.setProperty(IJazzScmConfigurationElement.PROPERTY_WORKSPACE_UUID, "_ZOldwI0VEeCBE-fD7bmXpg");
buildDefinition = buildClient.save(workingDefinitionCopy, new NullProgressMonitor());



Brent Ulbricht
RTC Build Lead

Ohhhh Brent,

That's perfect!!! I have either solved the issue by creating a build property by API called team.scm.WorkspaceUUID with value UUID of workspace I want before the build runs and it worked as well.

Thanks a lot for your quick and right reply Brent.

permanent link
Ananya Joisa (4552124) | answered Sep 12 '12, 7:57 a.m.
edited Sep 12 '12, 7:59 a.m.
Hi Brent,

I was initially getting the build definition as shown below using ITeamBuildService:

ITeamBuildService buildService = getService(ITeamBuildService.class);
        IBuildDefinition buildDef = buildService.getBuildDefinition(buildId);
        String buildDefId = buildDef.getId();

How is this different from getting build definition from ITeamBuildClient as you have shown in your answer above?
What is the difference between a TeamBuildService and a TeamBuildClient?
Thanks,

Ananya

permanent link
Michele Pegoraro (1.8k14118103) | answered Sep 14 '12, 4:08 a.m.

It depends if you're using PlainAPI (client side) or SDK (server side).

You can also change programmatically the repository workspace directly on the request (which is the instance of the build definition).

Michele.

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.