Can I access TeamCity programmatically?

I am trying to access a project on TeamCity to change vcs settings and artifacts paths. Is there a way I can do this via Java or anything else?

5 comments
Comment actions Permalink

You can write a Java plugin for TeamCity that will run as part of TeamCity (more). The plugin can expose an external API that can be called when you need that.

Also, the XML files in .BuildServer/config that store the configuration settings can be modified on disk.

Can you please describe what task are you trying to achieve?

0
Comment actions Permalink

I have projects that are set up as tags. I want to be able to change the svn checkout directory since the tag of the project can change.

Example:

Project: foo

current tag directory in TC is http://svn/tags/3.0/foo and I want to change this path to http://svn/tags/3.1/foo

0
Comment actions Permalink

Probably, you can change the setting directly in .BuildServer/config/vcs-roots.xml file. However, TeamCity can incorrectly detect changes in the first build since the VCS root change (the build will include the changes that were pending in the old VCS root on the moment of changing and will start to check changes in the updated VCS root only after the change.

If you do not need the changes reporting in TeamCity a workaround can be to do the whole checkout in your build script.

0
Comment actions Permalink

Thanks Yegor.

That was helpful. But as I digged more into it, I think what I would like to do is access TeamCity project settings( vcs setting, artifact paths, etc ) and modify them to my needs.
Do I need to write plugin for this? How do I even connect to my TeamCity instance? Do you have any reference to any examples? Very much appreciated.

0
Comment actions Permalink

So you have an option to modify TeamCity configuration files on disk ( in this case your code should access the file on the TeamCity server machine - this ca be done with some administration e.g. under Windows it can be done by sharing a directory)

And another option is to write a Java plugin for TeamCity that will acept HTTP requests (or any other that you implement in your code) and perform the actions based on the request. Example of the simpliest HTTP controller can be seen in HelloUserController class of sample plugin included into TeamCity distribution.

0

Please sign in to leave a comment.