It's all about the answers!

Ask a question

Change workspace build property programatically : Exception


Oscar Picasso (311420) | asked Apr 08 '14, 11:17 a.m.
 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.

One answer



permanent link
Oscar Picasso (311420) | answered Apr 08 '14, 1:32 p.m.
I solved it by query the defintion in RTC with buildClient.getBuildDefinition instead of using the build definition that was just created.

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.