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

Change workspace build property programatically : Exception

 Hi,

I tried something based on the example code in: https://jazz.net/forum/questions/57335/change-workspace-build-property-programatically?redirect=%2Fforum%2Fquestions%2F57335%2Fchange-workspace-build-property-programatically

IWorkspaceConnection buildWorkspace = ... create new repository workspace ...
UUID uuid = buildWorkspace.getContextHandle().getItemId();
IBuildDefinition definition = ... create new build defintion ...
IBuildDefinition workingDefinitionCopy = (IBuildDefinition) definition.getWorkingCopy();
workingDefinitionCopy.setProperty(IJazzScmConfigurationElement.PROPERTY_WORKSPACE_UUID,uuid.getUuidValue());
buildClient.save(workingDefinitionCopy, new NullProgressMonitor());
 
I get the following execption
Exception in thread "main" com.ibm.team.repository.common.InternalRepositoryException: CRJAZ0447I SQL statement execution failed.Integrity constraint violation
SQL: INSERT INTO BUILD.BUILD_DEFINITION (STATE_ID, ITEM_ID, CONTEXT_ID, MODIFIED, MODIFIED_BY_ITEM_ID, ID, PROCESS_AREA_ITEM_ID, JZ_PROCESS_AREA_DISCRIMINATOR) VALUES (?, ?, ?, ?, ?, ?, ?, ?)
SQL Exception #1
SQL Message: Violation of PRIMARY KEY constraint 'BLD_DFNTNPK'. Cannot insert duplicate key in object 'BUILD.BUILD_DEFINITION'. The duplicate key value is (_y76osL8iEeO3SKGeuzsLJg).
SQL State: 23000
Error Code: 2627
Class: com.ibm.team.repository.service.internal.dataaccess.write2.Row

The build definition is created on server but its repository workspace is not properly set.
If I remove the last save command, I get the same result on the server, except I don't get an Exception.

0 votes



One answer

Permanent link
I solved it by query the defintion in RTC with buildClient.getBuildDefinition instead of using the build definition that was just created.

1 vote

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,927

Question asked: Apr 08 '14, 11:17 a.m.

Question was seen: 4,477 times

Last updated: Apr 08 '14, 1:32 p.m.

Confirmation Cancel Confirm