It's all about the answers!

Ask a question

RTC API


Judy Yi (41133) | asked Aug 16 '10, 7:58 p.m.
Are there sample snippets to create build definitions, add users to administrator role in RTC Project using RTC JAVA API's? We were able to use the following link https://jazz.net/wiki/bin/view/Main/RTCSDK20_DevelopmentEnvironmentSetup to create stream, project areas, work items...

Thanks,
Judy

21 answers



permanent link
Nick Edgar (6.5k711) | answered Sep 01 '10, 11:39 a.m.
JAZZ DEVELOPER
To create a Build Forge build, use template id: "com.ibm.rational.connector.buildforge.ui.buildDefinitionTemplate"

The build definition id and other configuration properties can be set after initializing from the template but before saving the definition.
e.g.

definition.setId("RationalBuildForgeConnector");
definition.getConfigurationElement("com.ibm.rational.connector.buildforge")
.getConfigurationProperty("com.ibm.rational.connector.buildforge.project")
.setValue("My Project");


Other property names are as follows (taken from com.ibm.rational.connector.buildforge.common.builddefinition.BuildForgeConstants):


/**
* The Build Forge hostname.
*/
public static final String PROPERTY_BUILDFORGE_HOSTNAME = "com.ibm.rational.connector.buildforge.hostname"; //$NON-NLS-1$

/**
* The Build Forge port.
*/
public static final String PROPERTY_BUILDFORGE_PORT = "com.ibm.rational.connector.buildforge.port"; //$NON-NLS-1$

/**
* The Build Forge userid.
*/
public static final String PROPERTY_BUILDFORGE_USERID = "com.ibm.rational.connector.buildforge.userid"; //$NON-NLS-1$

/**
* The Build Forge password.
*/
public static final String PROPERTY_BUILDFORGE_PASSWORD = "com.ibm.rational.connector.buildforge.password"; //$NON-NLS-1$

/**
* The Build Forge connection mechanism, secure or non-secure.
*/
public static final String PROPERTY_BUILDFORGE_SECURE = "com.ibm.rational.connector.buildforge.secure"; //$NON-NLS-1$

/**
* The Build Forge project name.
*/
public static final String PROPERTY_BUILDFORGE_PROJECT = "com.ibm.rational.connector.buildforge.project"; //$NON-NLS-1$

/**
* The Build Forge project name.
*/
public static final String PROPERTY_BUILDFORGE_PROJECT_UUID = "com.ibm.rational.connector.buildforge.project.uuid"; //$NON-NLS-1$

/**
* The Build Forge first X step logs added to logs tab.
*/
public static final String PROPERTY_BUILDFORGE_FIRST_LOGS = "com.ibm.rational.connector.buildforge.logs.first"; //$NON-NLS-1$

/**
* The Build Forge last X step logs added to logs tab.
*/
public static final String PROPERTY_BUILDFORGE_LAST_LOGS = "com.ibm.rational.connector.buildforge.logs.last"; //$NON-NLS-1$

/**
* The Build Forge first X step logs added to logs tab, check box enabled.
*/
public static final String PROPERTY_BUILDFORGE_FIRST_LOGS_ENABLED = "com.ibm.rational.connector.buildforge.logs.first.enabled"; //$NON-NLS-1$

/**
* The Build Forge last X step logs added to logs tab, check box enabled.
*/
public static final String PROPERTY_BUILDFORGE_LAST_LOGS_ENABLED = "com.ibm.rational.connector.buildforge.logs.last.enabled"; //$NON-NLS-1$

/**
* The Build Forge all step logs added to logs tab.
*/
public static final String PROPERTY_BUILDFORGE_ALL_LOGS = "com.ibm.rational.connector.buildforge.logs.all"; //$NON-NLS-1$

/**
* The Build Forge all step logs not passed or skipped added to logs tab.
*/
public static final String PROPERTY_BUILDFORGE_ALL_LOGS_NOT_PASSED_OR_SKIPPED = "com.ibm.rational.connector.buildforge.logs.all.not.passed.or.skipped"; //$NON-NLS-1$

/**
* The Build Forge custom BOM data added to logs tab.
*/
public static final String PROPERTY_BUILDFORGE_CUSTOM_BOM = "com.ibm.rational.connector.buildforge.bom.custom"; //$NON-NLS-1$

permanent link
Dashrath Kale (1542723) | answered Sep 02 '10, 7:05 a.m.
To create a Build Forge build, use template id: "com.ibm.rational.connector.buildforge.ui.buildDefinitionTemplate"

The build definition id and other configuration properties can be set after initializing from the template but before saving the definition.
e.g.

definition.setId("RationalBuildForgeConnector");
definition.getConfigurationElement("com.ibm.rational.connector.buildforge")
.getConfigurationProperty("com.ibm.rational.connector.buildforge.project")
.setValue("My Project");


Other property names are as follows (taken from com.ibm.rational.connector.buildforge.common.builddefinition.BuildForgeConstants):


/**
* The Build Forge hostname.
*/
public static final String PROPERTY_BUILDFORGE_HOSTNAME = "com.ibm.rational.connector.buildforge.hostname"; //$NON-NLS-1$

/**
* The Build Forge port.
*/
public static final String PROPERTY_BUILDFORGE_PORT = "com.ibm.rational.connector.buildforge.port"; //$NON-NLS-1$

/**
* The Build Forge userid.
*/
public static final String PROPERTY_BUILDFORGE_USERID = "com.ibm.rational.connector.buildforge.userid"; //$NON-NLS-1$

/**
* The Build Forge password.
*/
public static final String PROPERTY_BUILDFORGE_PASSWORD = "com.ibm.rational.connector.buildforge.password"; //$NON-NLS-1$

/**
* The Build Forge connection mechanism, secure or non-secure.
*/
public static final String PROPERTY_BUILDFORGE_SECURE = "com.ibm.rational.connector.buildforge.secure"; //$NON-NLS-1$

/**
* The Build Forge project name.
*/
public static final String PROPERTY_BUILDFORGE_PROJECT = "com.ibm.rational.connector.buildforge.project"; //$NON-NLS-1$

/**
* The Build Forge project name.
*/
public static final String PROPERTY_BUILDFORGE_PROJECT_UUID = "com.ibm.rational.connector.buildforge.project.uuid"; //$NON-NLS-1$

/**
* The Build Forge first X step logs added to logs tab.
*/
public static final String PROPERTY_BUILDFORGE_FIRST_LOGS = "com.ibm.rational.connector.buildforge.logs.first"; //$NON-NLS-1$

/**
* The Build Forge last X step logs added to logs tab.
*/
public static final String PROPERTY_BUILDFORGE_LAST_LOGS = "com.ibm.rational.connector.buildforge.logs.last"; //$NON-NLS-1$

/**
* The Build Forge first X step logs added to logs tab, check box enabled.
*/
public static final String PROPERTY_BUILDFORGE_FIRST_LOGS_ENABLED = "com.ibm.rational.connector.buildforge.logs.first.enabled"; //$NON-NLS-1$

/**
* The Build Forge last X step logs added to logs tab, check box enabled.
*/
public static final String PROPERTY_BUILDFORGE_LAST_LOGS_ENABLED = "com.ibm.rational.connector.buildforge.logs.last.enabled"; //$NON-NLS-1$

/**
* The Build Forge all step logs added to logs tab.
*/
public static final String PROPERTY_BUILDFORGE_ALL_LOGS = "com.ibm.rational.connector.buildforge.logs.all"; //$NON-NLS-1$

/**
* The Build Forge all step logs not passed or skipped added to logs tab.
*/
public static final String PROPERTY_BUILDFORGE_ALL_LOGS_NOT_PASSED_OR_SKIPPED = "com.ibm.rational.connector.buildforge.logs.all.not.passed.or.skipped"; //$NON-NLS-1$

/**
* The Build Forge custom BOM data added to logs tab.
*/
public static final String PROPERTY_BUILDFORGE_CUSTOM_BOM = "com.ibm.rational.connector.buildforge.bom.custom"; //$NON-NLS-1$


Hi Nick,

Thanks again for the information, I have added the below jars in the lib directory of my JAVA project and we can see the Build Forge tab in the build definition.
1)com.ibm.rational.connector.buildforge.common_7.1.1.3020013.jar
2)com.ibm.rational.connector.buildforge.service_7.1.1.3020013.jar
3)com.ibm.rational.connector.buildforge.ui_7.1.1.3020013.jar
4)com.ibm.rational.buildforge.services.client.java_7.1.1.3020013.jar

but getting the java.lang.NullPointerException while getting the ConfigurationProperty with the below code:

definition.getConfigurationElement("com.ibm.rational.connector.buildforge")
.getConfigurationProperty("com.ibm.rational.connector.buildforge.project")
.setValue("My Project");


I can see these properties in the plugin.xml file for com.ibm.rational.connector.buildforge.common_7.1.1.3020013.jar
Could you please help to resolve this issue.

permanent link
Nick Edgar (6.5k711) | answered Sep 02 '10, 7:33 a.m.
JAZZ DEVELOPER
You should not need the server and UI jars in your classpath. You will need the .common one to gain access to the extension for the BF template.

re the NPE, are you doing this after initializing the definition from the BF template?
The config element it's looking up will not be there until you do.

permanent link
Dashrath Kale (1542723) | answered Sep 02 '10, 10:25 a.m.
You should not need the server and UI jars in your classpath. You will need the .common one to gain access to the extension for the BF template.

re the NPE, are you doing this after initializing the definition from the BF template?
The config element it's looking up will not be there until you do.


Thanks Nick , you are correct , issue is resolved now.
Now we need to add the schedule in build definition , I have searched for the schedule properties for buildConfigurationElement"com.ibm.team.build.schedule"in plugin.xml file for com.ibm.team.build.common jar and com.ibm.rational.connector.buildforge.common_7.1.1.3020013.jar but haven't got any schedule properties there.Could you please provide the details on setting the build schedules and setting schedule properties. and It will be great if we get these details for buildConfigurationElement "com.ibm.team.build.properties" and "com.ibm.team.build.general".

Thanks,
Dashrath

permanent link
Nick Edgar (6.5k711) | answered Sep 02 '10, 11:33 a.m.
JAZZ DEVELOPER
The build schedule is a helper item that's part of the main IBuildDefinition.
Try:

IBuildDefinition definition = ...
IBuildSchedule schedule = definition.getBuildSchedule();
schedule.setScheduleEnabled(true);
schedule.setBuildOnMonday(true);
schedule.setBuildInterval(30); // every 30 minutes
// save build definition as before

permanent link
Dashrath Kale (1542723) | answered Sep 03 '10, 4:50 a.m.
The build schedule is a helper item that's part of the main IBuildDefinition.
Try:

IBuildDefinition definition = ...
IBuildSchedule schedule = definition.getBuildSchedule();
schedule.setScheduleEnabled(true);
schedule.setBuildOnMonday(true);
schedule.setBuildInterval(30); // every 30 minutes
// save build definition as before


Hi Nick,

I can add the schedule,I can change the Pruning policy and ignore warnings in Overview section of the build definition.

But I can't do the below:
1) Can't add the build properties in the properties section of build definition.
2) Can we enable/select the BuildEngine in Supporting build engines section of Overview tab in build definition programmitcally (I can see the "RationalBuildForgeConnector" in supporting build engines section but it is not enabled/selected) ?.

Could you please help.

permanent link
Nick Edgar (6.5k711) | answered Sep 03 '10, 2:21 p.m.
JAZZ DEVELOPER
For (1), use buildDefinition.getProperties().add(property) where the property is created via BuildItemFactory.createBuildProperty(), and you can set its name/value/description.

For (2), engine/definition associations are maintained on the BuildEngine, not the BuildDefinition. Fetch the BuildEngine item, getWorkingCopy(), then add the definition handle to engine.getSupportedBuildDefinitions(), then save the engine.

permanent link
Dashrath Kale (1542723) | answered Sep 06 '10, 6:26 a.m.
For (1), use buildDefinition.getProperties().add(property) where the property is created via BuildItemFactory.createBuildProperty(), and you can set its name/value/description.

For (2), engine/definition associations are maintained on the BuildEngine, not the BuildDefinition. Fetch the BuildEngine item, getWorkingCopy(), then add the definition handle to engine.getSupportedBuildDefinitions(), then save the engine.


Nick , I can add the build properties.

and I have written below code to enable the Build Engine for newly created build definition , this code gets executed successfully but I can't see the build engine enabled for rge newly created build definition, could you please help to get this resolved.

			definition = ClientFactory.getTeamBuildClient(repo).save(

definition, new NullProgressMonitor());

ITeamBuildClient buildClient = (ITeamBuildClient) repo
.getClientLibrary(ITeamBuildClient.class);

IBuildEngine buildEngine = buildClient.getBuildEngine(
"RationalBuildForgeConnector", monitor);

IBuildEngine buildEngine_WorkingCopy = (IBuildEngine) buildEngine.getWorkingCopy();

buildEngine_WorkingCopy.setActive(true);
buildEngine_WorkingCopy.supportsBuildDefinition(definition);
buildEngine_WorkingCopy = ClientFactory.getTeamBuildClient(repo).save(
buildEngine_WorkingCopy, new NullProgressMonitor());

permanent link
Nick Edgar (6.5k711) | answered Sep 06 '10, 3:55 p.m.
JAZZ DEVELOPER
The supportsBuildDefinition method is a test for whether the engine supports the given definition; it does not make any modifications. As mentioned above, you need to add the definition handle to the list of supported definitions.
e.g.
buildEngine_WorkingCopy.getSupportedBuildDefinitions().add(definition);

permanent link
Dashrath Kale (1542723) | answered Sep 07 '10, 7:33 a.m.
The supportsBuildDefinition method is a test for whether the engine supports the given definition; it does not make any modifications. As mentioned above, you need to add the definition handle to the list of supported definitions.
e.g.
buildEngine_WorkingCopy.getSupportedBuildDefinitions().add(definition);


Nick

Finally, we can create the build definition as required.

THANK YOU VERY MUCH!!! for your help and quick response on every issue with much details.

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.