RTC Java Api Remove Build Engine from Build Definition
![]() I try to remove BuildEngine from BuildDefinition and it doesn't work!
My code:
IBuildEngine be = client.getBuildEngine(id, monitor)
If I use following add, it's work fine:
The following code return false:
I am very confuse... Someone have an idea? Thanks in advance. |
3 answers
![]()
I think its an api issue.. add() and remove() will use the IBuildDefinitionHandle..
Contains() is a java object list method.. getSupportedBuildDefinitions() returns a list of HANDLES.(IBuildDefinitionHandle). not objects (IBuildDefinition) but then you asked does this IBuildDefinition (object address, NOT HANDLE), exist in the list of HANDLES..(IBuildDefinitionHandle) and it does not.. |
![]()
Sridevi Sangaiah (591●7●9)
| answered Sep 12 '16, 9:03 p.m.
JAZZ DEVELOPER edited Sep 12 '16, 9:04 p.m.
Remove could also be failing for the same reason like contains, unless BuildDefinitionHandleImpl implements the equals and hashcode methods, which I doubt. Can you please try the following snippet for remove?
String id = someBuildEngineId; IBuildDefinition buildDefinition = someBuildDefinition; IBuildEngine be = client.getBuildEngine(id, monitor) IBuildEngine workingCopy = (IBuildEngine) be.getWorkingCopy(); List buildDefinitionHandles = workingCopy .getSupportedBuildDefinitions(); for (int j = 0; j < buildDefinitionHandles.size(); j++) { IBuildDefinitionHandle handle = (IBuildDefinitionHandle) buildDefinitionHandles.get(j); if (buildDefinition .getItemId().getUuidValue().equals(buildDefinitionHandle.getItemId().getUuidValue())) { workingCopy.getSupportedBuildDefinitions().remove(j); client.save(workingCopy, monitor); break; } } Thanks, Sridevi Comments I think it could have been done with
|
![]() Good morning, It's work fine! Thanks you very much for your help, it's very appreciate it. Have a good day. |
Comments
If "workingCopy.getSupportedBuildDefinitions().contains(buildDefinition)" returns false then there is a possibility that the build definition is not supported by the build engine.
Can you please confirm from the UI that when you add a build definition, in your code, it gets added to the build engine and then when you programatically remove the build definition it is not removed?
Thanks,
Sridevi
Hello Sridevi,
Thanks for your quick response. I can confirm from UI that I can add new Build Engine X but I can't remove them.
I use artifact com.ibm.team.build.common:3.1.400.v20130415_0257
Thanks a lot it's very appreciate it.