Jazz Forum Welcome to the Jazz Community Forum Connect and collaborate with IBM Engineering experts and users

Change workspace build property programatically

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

0 votes



4 answers

Permanent link
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

1 vote


Permanent link
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.

0 votes


Permanent link
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

0 votes


Permanent link

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.

0 votes

Your answer

Register or log in 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.

Search context
Follow this question

By Email: 

Once you sign in you will be able to subscribe for any updates here.

By RSS:

Answers
Answers and Comments
Question details
× 10,938

Question asked: Jun 19 '11, 2:51 p.m.

Question was seen: 7,035 times

Last updated: Sep 14 '12, 4:08 a.m.

Confirmation Cancel Confirm