How to create Build Definition via SDK API?
![](http://jazz.net/_images/myphoto/bf7409df9b566a51b9933904429d4365.jpg)
Accepted answer
One other answer
![](http://jazz.net/_images/myphoto/bf7409df9b566a51b9933904429d4365.jpg)
I find the following code in SDK test jar, but run with expection, any one can help?
String templateId = "com.ibm.team.build.ant";
java.lang.IllegalArgumentException: Item Handle must not be null
at com.ibm.team.repository.service.internal.RepositoryItemService.fetchItem(RepositoryItemService.java:493)
at sun.reflect.GeneratedMethodAccessor276.invoke(null)
Thanks!
String templateId = "com.ibm.team.build.ant";
private static IBuildDefinition createBuildDefinition(ITeamRepository repo, IProcessAreaHandle processAreaHandle, String templateId, String definitionId) throws Exception {
IBuildDefinition definition = null;
IBuildDefinitionTemplate template = BuildConfigurationRegistry.getInstance().getBuildDefinitionTemplate(templateId);
if (template != null) {
definition = BuildItemFactory.createBuildDefinition();
definition.setProcessArea(processAreaHandle);
definition.setId(definitionId);
definition.initializeConfiguration(template);
definition = ClientFactory.getTeamBuildClient(repo).save(definition, new NullProgressMonitor());
}
return definition;
}
java.lang.IllegalArgumentException: Item Handle must not be null
at com.ibm.team.repository.service.internal.RepositoryItemService.fetchItem(RepositoryItemService.java:493)
at sun.reflect.GeneratedMethodAccessor276.invoke(null)
Thanks!