0241837 Mar 15, 2008
kohsuke doc improvement
0 contributors

Users who have contributed to this file

39 lines (32 sloc) 1.29 KB
package org.jvnet.hudson.client_demo;
import org.dom4j.Document;
import org.dom4j.Element;
import java.util.List;
* Java client program to demonstrate how to access Hudson remote API.
* @author Kohsuke Kawaguchi
* @see
public class Main {
public static void main(String[] args) throws Exception {
// every Hudson model object exposes the .../api/xml, but in this example
// we'll just take the root object as an example
URL url = new URL("");
// if you are calling security-enabled Hudson and
// need to invoke operations and APIs that are protected,
// consult the 'SecuredMain" class
// in this package for an example using HttpClient.
// read it into DOM.
Document dom = new SAXReader().read(url);
// scan through the job list and print its status
for( Element job : (List<Element>)dom.getRootElement().elements("job")) {
job.elementText("name"), job.elementText("color")));