It's all about the answers!

Ask a question

Can the rtc workspace be changed in a builddef using the java api


K M (38325051) | asked May 05 '15, 11:35 a.m.
I can retrieve the builddef and its elements but I can find the workspace properties for the Jazz source control element.

2 answers



permanent link
Arne Bister (2.6k12832) | answered May 07 '15, 8:54 a.m.
JAZZ DEVELOPER
K M,

the trick is to
import com.ibm.team.build.internal.common.builddefinition.IJazzScmConfigurationElement;
Then get your build definition:
IBuildDefinition buildDef = ClientFactory.getTeamBuildClient(teamRepository).getBuildDefinition(buildDefId, null);

read the Build workspace property:
String wsUUID = buildDef.getConfigurationPropertyValue(IJazzScmConfigurationElement.ELEMENT_ID, 
     IJazzScmConfigurationElement.PROPERTY_WORKSPACE_UUID, null);

If this returns the default value (null in this example) it was not set. You might have to create the SCM configuration element if that is also not present yet.

To change workspace property to a new String workspaceUUID, get a working copy of buildDef, set the property and save:
IBuildDefinition copyBuildDef = (IBuildDefinition) buildDef.getWorkingCopy();
copyBuildDef.setConfigurationProperty(IJazzScmConfigurationElement.ELEMENT_ID,IJazzScmConfigurationElement.PROPERTY_WORKSPACE_UUID, workspaceUUID);                    
copyBuildDef = ClientFactory.getTeamBuildClient(repo).save(copyBuildDef, null);



If this answers your question, please mark the answer as accepted.
Best,

Arne

Comments
K M commented May 07 '15, 11:05 a.m.

that does the trick, the next question is how to change the Post-build Deliver element properties

ie the target stream


K M commented May 07 '15, 11:05 a.m.

that does the trick, the next question is how to change the Post-build Deliver element properties

ie the target stream


K M commented May 07 '15, 12:50 p.m.

I can use
        List <IBuildProperty> k_props = buildDef.getProperties();

and l look for team.scm.deliver.targetUUID


permanent link
Stefano Antoniazzi (1701711) | answered Sep 27 '17, 4:51 a.m.
edited Sep 27 '17, 4:54 a.m.

  Even if this is an old question, maybe somebody may find something similar to what I get, that is a bit different from the answer I read here.

I'm using RTC 4.0.7. 

If I use getConfigurationPropertyValue I don't get the right property value, while everything works if I use directly getProperty.

I mean

    String wrongResult = buildDefinition.getConfigurationPropertyValue(IJazzScmConfigurationElement.ELEMENT_ID, IJazzScmConfigurationElement.PROPERTY_WORKSPACE_UUID, null);
gives back "null" while

    IBuildProperty rightResult = buildDefinition.getProperty(IJazzScmConfigurationElement.PROPERTY_WORKSPACE_UUID);
gives back a correct build property from which I may get name and value (getValue() and getName())

In particular if I want to investigate all the "IBuildConfigurationElement" of a Build definition I get a strange result.
With this code:
    List<IBuildConfigurationElement> buildConfigurationElements = buildDefinition.getConfigurationElements();

for (IBuildConfigurationElement buildConfigurationElement : buildConfigurationElements) {

log.trace("+buildDefinitionn id==" + buildDefinition.getId() + "== buildConfigurationElementt id=>" + buildConfigurationElement.getElementId() + "== name ==" + buildConfigurationElement.getName() + "==");
List<IConfigurationProperty> configurationProperties = buildConfigurationElement.getConfigurationProperties(); for (IConfigurationProperty configurationProperty : configurationProperties) {
log.trace("--configurationProperty  name ==" + configurationProperty.getName() + "== value==" +  configurationProperty.getValue() + "=="); } }

I get this output:
+buildDefinitionn id==Build_CD_WEB_XCD_Copy== buildConfigurationElementt id==com.ibm.team.build.general== name ==General==
+buildDefinitionn id==Build_CD_WEB_XCD_Copy== buildConfigurationElementt id==com.ibm.team.build.schedule== name ==Schedule==
+buildDefinitionn id==Build_CD_WEB_XCD_Copy== buildConfigurationElementt id==com.ibm.team.build.properties== name ==Properties==
+buildDefinitionn id==Build_CD_WEB_XCD_Copy== buildConfigurationElementt id==com.ibm.team.build.jazzscm== name ==Jazz Source Control==
--configurationProperty  name ==com.ibm.team.build.engine.variable.substitution== value====
+buildDefinitionn id==Build_CD_WEB_XCD_Copy== buildConfigurationElementt id==com.ibm.team.build.ant== name ==Ant==
--configurationProperty  name ==com.ibm.team.build.ant.buildFile== value==D:\C:\BUILD\ANT\dummy.xml==
--configurationProperty  name ==com.ibm.team.build.ant.targets== value====
--configurationProperty  name ==com.ibm.team.build.ant.antArgs== value==-v -d==
--configurationProperty  name ==com.ibm.team.build.ant.antHome== value====
--configurationProperty  name ==com.ibm.team.build.ant.javaHome== value====
--configurationProperty  name ==com.ibm.team.build.ant.javaVMArgs== value====
--configurationProperty  name ==com.ibm.team.build.ant.workingDir== value==${destDir}==
--configurationProperty  name ==com.ibm.team.build.ant.propertiesFile== value==${destDir}/fromRTC.properties==
--configurationProperty  name ==com.ibm.team.build.ant.includeToolkit== value==true==
--configurationProperty  name ==com.ibm.team.build.engine.variable.substitution== value====   
so it seems to me that only "com.ibm.team.build.ant" aka "IAntConfigurationElement.ELEMENT_ID" has a structure for getting  IBuildConfigurationElement


Comments
Stefano Antoniazzi commented Sep 27 '17, 8:04 a.m. | edited Sep 27 '17, 8:05 a.m.

 Notice that this behavior is similar to what is written in Nick Edgar comment about "SCM workspace UUID" here: https://jazz.net/forum/questions/140583/copy-build-definition-error-help/140696

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.