Possible to create Hudson/Jenkins build def via API?
When I list build templates via:
IBuildDefinitionTemplate[] templates = BuildConfigurationRegistry.getInstance().getBuildDefinitionTemplates();
for (IBuildDefinitionTemplate template : templates) {
System.out.println(" Template Name: "+template.getName());
System.out.println(" Template Id : "+template.getId());
}
I don't see an option for a Hudson/Jenkins build template listed...
Output from above:
Template Name: Ant - Jazz Build Engine
Template Id : com.ibm.team.build.ant
Template Name: Command Line - Jazz Build Engine
Template Id : com.ibm.team.build.cmdline
Template Name: Maven - Jazz Build Engine
Template Id : com.ibm.team.build.maven
Template Name: Generic
Template Id : com.ibm.team.build.generic
Template Name: Jazz Build for Microsoft Visual Studio Solution - Jazz Build Engine
Template Id : com.ibm.team.build.msbuild
When I attempt to create a build definition from a Hudson/Jenkins template via plain Java API, I get null pointer exceptions, presumably due to the missing template.
Code:
IBuildDefinitionTemplate HJtemplate = null;
try {
HJtemplate = BuildConfigurationRegistry.getInstance().getBuildDefinitionTemplate("com.ibm.rational.connector.hudson");
} catch (NullPointerException e) {
System.out.println("NPE caught: "+ e.getMessage());
}
try {
jenkinsbdWC.initializeConfiguration(HJtemplate);
} catch (NullPointerException e) {
System.out.println("NPE caught: "+ e.getMessage());
}
The initializeConfiguration call throws a NPE, with this output:
NPE caught: null
What am I missing? Running with RTC4.0.3 Gold...thanks in advance.
Accepted answer
Hi Todd, what are you using as your target set of plugins? If you're using the plugins directory from the build system toolkit (either JBE under buildsystem/buildengine/eclipse/plugins/, or the Ant tasks under buildsystem/buildtoolkit/), then this is missing the plugin containing the extension for the Hudson/Jenkins template (since JBE doesn't need to know about the H/J support). The plugin you want is com.ibm.rational.connector.hudson.common. For the relevant configuration element id, and config property names (e.g. for setting the Jenkins job name etc), see constants in com.ibm.rational.connector.hudson.internal.common.HudsonConfigurationElement, especially PROPERTY_HUDSON_JOB.
There's also a small client library in com.ibm.rational.connector.hudson.client, which lets you run a connection test, fetch the available jobs, etc. See methods on com.ibm.rational.connector.hudson.internal.client.IHudsonServiceClient. You don't need this, though, if you already know the job name.
Comments
showing 5 of 6
show 1 more comments
Comments
sam detweiler
Jan 03 '14, 10:58 a.m.Todd Strangio
Jan 03 '14, 11:06 a.m.sam detweiler
Jan 03 '14, 11:11 a.m.Todd Strangio
Jan 03 '14, 2:20 p.m.sam detweiler
Jan 04 '14, 8:38 a.m.Todd Strangio
Jan 06 '14, 8:26 a.m.