In this section, you'll learn how to connect to a Continuum instance and how to do some action on projects.
To connect to a Continuum instance, you must use the continuum-xmlrpc-client jar.
This library have some others jars as dependencies, so the best way to start the development of a Continuum xmlrpc client is to create a maven2 project with the following dependencies:
<dependency> <groupId>org.apache.continuum</groupId> <artifactId>continuum-xmlrpc-client</artifactId> <version>YOUR_CONTINUUM_VERSION</version> </dependency>
To connect to your Continuum with the client API, you must use the ContinuumXmlRpcClient class.
The constructor use 3 parameters:
URL url = new URL( "http://localhost:8080/continuum/xmlrpc" ); ContinuumXmlRpcClient client = new ContinuumXmlRpcClient( url, username, password );
You have two ways to get the project groups list. The first is to get only a summary of groups and the second returns groups with details. If you don't need all informations, we recommend to use the first way, so you'll save time to get datas and memory on the server.
List<ProjectGroupSummary> pgs = client.getAllProjectGroups(); List<ProjectGroup> pgs = client.getAllProjectGroupsWithProjects();
List<ProjectSummary> ps = client.getProjects( projectGroupId );
If you already have a ProjectGroup or ProjectGroupSummary object, you can access to the project group id with this:
int projectGroupId = pg.getId();
client.buildGroup( projectGroupId );
client.buildGroup( projectGroupId, buildDefinitionId );
client.buildProject( project.getId() );
client.buildProject( project.getId(), buildDefinitionId );
Note: When you start a build, the project is put in the Continuum queue and will be built when all projects added previously in the queue will be built.
In some case, users want to use the push build technique with a hook in their SCM, so when a developer will commit some files, a build will be triggered. To do this, you can write a simple xmlrpc client that will use a project id as parameter and you'll use the buildProject(...) method described above.
This method will start a forced build.
A project can be removed by supplying the project id.
List<ProjectSummary> projects = client.getProjects( projectGroupId ); ... client.removeProject( ps.getId() );
Currently, to remove a build result, you need the entire build result (rather than just the summary).
List<BuildResultSummary> results = client.getBuildResultsForProject( ps.getId() ); ... BuildResult br = client.getBuildResult( ps.getId(), brs.getId() ); client.removeBuildResult( br );
You can edit all projects which are in the build queue or check if one project is currently in the build queue.
List<BuildProjectTask> prjsInBuildQueue = client.getProjectsInBuildQueue(); client.isProjectInBuildingQueue( int projectId );
With the Continuum xmlrpc client, you can backup a full Continuum instance (without users database, for the moment).