How to use Spring Framework to access TeamCity build server?

It's been over 8 years since I've developed in Java - pretty much a C++, Ruby and C# person, let alone access using Spring Framework.  I'm missing some knowledge when trying to read up on Spring Framework.  Is there some simple sample Java code someplace that shows how to 'grab' a reference to a TeamCity object, BuildServer, ProjectManager, etc. so I can check the 'state' of BuildTypes, agents and other stuff?  I've looked a few and pieces of code, one using RemoteBuildServerFacade, and I can't resolve nor find this object.  I'm trying to access TC like the system tray does in Windows.

Your help will be greatly appreciated.

Dave

8 comments
Comment actions Permalink

Most of the TeamCity services are defined as Spring beans. To get access to Spring bean you need to define your own Spring bean and ask for a service in a constructor. When Spring creates beans it automatically provides services required by your class, this is called autowiring.

To define your class as a Spring bean you need to write a little xml file and put it into the META-INF folder:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd">

<beans default-autowire="constructor">
  <bean name="yourBeanName" />
</beans>

0
Comment actions Permalink

Thanks.  But is there a way to access all this 'stuff' within a 'main' function of an application?  Many build systems offer 'direct access' to their API and this is not very straight forward to someone not living in the Java world.  As I mentioned above the 'Tray Notifier' has access and it doesn't even look like Java code.

This is the type of access I need to TeamCity.  If saying the Spring Framework was the wrong way to ask, I'm sorry.  But getting access from a regular old program, Java or otherwise, is what I'm looking for.

Thanks.

Dave

0
Comment actions Permalink

You want to write a standalone tool which will communicate with TeamCity server by a network protocol (HTTP)?

0
Comment actions Permalink

Yes, but it doesn't have to HTTP protocol.  What ever is simplest in that flavor of application.  I just want a standalone application to 'do stuff' with TeamCity.  Monitor, check build stats, etc.

Thanks.

0
Comment actions Permalink

Ok, I understand. I think you'll still need a server side plugin which will provide necessary information for you. Plugin can be accessed by HTTP or XML-PRC.

So if you choose to use XML-RPC you will need an XML-RPC client library for your standalone tool and (optionally) you will need to register your XML-RPC handler at the server side. Custom XML-RPC handler is required if you need to provide your own XML-RPC API. If you choose to use HTTP then you will need HTTP client library and custom controller registered at the server side.

TeamCity already has its own XML-RPC API (see jetbrains.buildServer.serverProxy.RemoteBuildServer interface) however to access this API you need to be authenticated. If you choose to write standalone tool using Java you can use jetbrains.buildServer.serverProxy.impl.SessionXmlRpcTargetImpl class. However it is not as easy if you plan to use .NET: currently we do not provide similar API for .NET.

In Java you can also try to use jetbrains.buildServer.serverProxy.RemoteBuildServerFacade. It can simplify things.

0
Comment actions Permalink

Thanks for the quick reply.

I've seen some postings using the 'RemoteBuildServerFacade', but I couldn't find the class any were.  Where is it located?

0
Comment actions Permalink

Well, at the moment it is not a part of our Open API. However you can get this class from the jar packed with IntelliJ IDEA plugin (buildServer4Idea.jar).

0
Comment actions Permalink

Ah.  There's the ticket.  Thank you very much for you time.  I think I can work with that now.

Dave

0

Please sign in to leave a comment.