import groovy.util.XmlSlurper import groovy.net.xmlrpc.* import java.util.Map import java.util.HashMap import java.net.ServerSocket import org.apache.commons.httpclient.* import org.apache.xmlrpc.client.* public class BugzillaCreateFromXML { public static void main(String[] args) { // get the xml data of our issues in the .xml file def xmlData = new XmlSlurper().parse(new File("C:/issues.xml")) def httpClient = new HttpClient() def rpcClient = new XmlRpcClient() def factory = new XmlRpcCommonsTransportFactory(rpcClient) def config = new XmlRpcClientConfigImpl() factory.setHttpClient(httpClient) rpcClient.setTransportFactory(factory) config.setServerURL(new URL("http://bugzilla-addres/xmlrpc.cgi")) rpcClient.setConfig(config) // map of the login data Map loginMap = new HashMap() loginMap.put("login", "admin") loginMap.put("password", "admin") loginMap.put("rememberlogin", "Bugzilla_remember") // login to bugzilla def loginResult = rpcClient.execute("User.login", loginMap) println loginResult // map of the bug data Map bugMap = new HashMap() // iterate through each issue xmlData.issue.each { bugMap.put("product", it.product.text()) bugMap.put("component", it.component.text()) bugMap.put("summary", it.summary.text()) bugMap.put("version", it.version.text()) bugMap.put("description", it.description.text()) bugMap.put("op_sys", it.opsys.text()) bugMap.put("platform", it.platform.text()) bugMap.put("priority", it.priority.text()) bugMap.put("severity", it.severity.text()) bugMap.put("status", it.status.text()) // create bug def createResult = rpcClient.execute("Bug.create", bugMap) println createResult // clear bugMap so we can re-populate it with the next issue bugMap.clear() } } }