Project
TeamCity
Priority
Critical
Type
Feature
State
Fixed
Assignee
Yegor Yarko
Subsystem
Server
Affected versions
No Affected versions
Fix versions
Faradi 7.0 EAP (21075), Faradi 7.0 (21241)
Fixed in build
No Fixed in build
Fixed in builds
no build yet
  • Created by   James Strachan
    2 years ago (04 Jun 2009 14:55)
  • Updated by   Tony Esposito
    2 months ago (19 Mar 2012 18:51)
 
TW-8394 Ability to manage projects/build configurations remotely via API
31
Issue is visible to: All Users
  The issue is visible to the selected user group only
Being able to browse/add/update/remove projects and build configurations via HTTP/REST programatically.

Current workarounds:
  • write TeamCity Java/Groovy/JRuby plugin with full access to object mode via openAPI, expose required API from the plugin
  • generate necessary XMLs under .BuildServer/config caring about correct structure and unique IDs. See also some related notes in a comment
  • (for adding new projects and build configurations) create a "template" project or build configuration and then copy it from en external tool emulating user's copy action from the web browser, in line with the notes.


    --- original issue text:

e.g. we could then write a script to look for project

http://myserver/builds/someProject

if it didn't exist we could POST a blob of XML (or JSON - don't care, whatever you prefer) to this URL to create a new project (or PUT to update its settings).

Then we can find the builds for each project again via HTTP/REST and add/remove builds that way.

This would then make it easy for folks to manage the various builds and their configurations using any language/technology.

Some background: We're hosting a ton of projects; we use a Rails application to create them and their resources (JIRA, wik, git repos and so forth). It would be great if we could just do a few HTTP GET/POSTs to setup projects in TeamCity - we could then some well defined templates of builds (e.g. a nightly, checkin and deploy build for each project - the only thing that changes for each project is typically its name and its VCS location)
Comments (48)
 
History
 
Linked Issues (?)
 
Yegor Yarko
  Yegor Yarko
23 Jun 2009 22:29
2 years ago
For now this is only possible if a custom plugin is written. We will certainly consider to add this to our REST API, when it becomes available
Related Changes
Type
BugException
State
SubmittedOpen
Assignee
<no user>Pavel Sher (pavel.sher)
Chris Walquist
  Chris Walquist
14 Dec 2009 21:35
2 years ago
We have about 190 projects and 800 build configurations. Similarly to James' description, developers would like our team to wrap up our company-specific conventions for TeamCity (and related resources) and put it in their hands (we'll probably also do it in Rails). Our deployment system for instance has quite a complete remoting API, but TeamCity is lacking one. A well-designed and highly functional REST api would be a tremendous help.
Yegor Yarko
  Yegor Yarko
05 Aug 2010 16:31
21 months ago
Anthony Milbourne
  Anthony Milbourne
08 Sep 2010 20:23
20 months ago
This would also be useful to our organisation. The solution above (directly editing XML config) is not usable as we run a shared instance of the server and could not guarantee that users were not changing config at the same time. It would be great if you could implement an admin API.
Simone Busoli
  Simone Busoli
08 Sep 2010 21:46
20 months ago
Anthony, what do you mean by "shared instance"?
Anthony Milbourne
  Anthony Milbourne
09 Sep 2010 12:42
20 months ago
We have several teams building projects on that server and each administers their own project(s). Because of timezones and late working it would be awkward to 'close the server' while a script edited the config - not to mention the fact that changes would need to be batched, which would partially defeat the point of an automated system.
Simone Busoli
  Simone Busoli
09 Sep 2010 23:06
20 months ago
Ok I can see what you mean, I thought you were using multiple instances of the server pointing to the same configuration, which left me surprised.
Yegor Yarko
  Yegor Yarko
13 Sep 2010 21:00
20 months ago
Anthony,

Can you detail why do you need to do automated changes to the configurations (probably with use cases)?
Can you list the operations that you need most to do remotely?
Anthony Milbourne
  Anthony Milbourne
13 Sep 2010 21:10
20 months ago
There is only one use case really. When a new project starts up we want to be able to create all the infrastructure in one go, so the subversion repository, the CI project the Issue tracking project, etc. Hence we want an interface that talks to all the different apps and creates the relevant config. So we would like the ability to create a new project (bare minimum), and ideally the ability to create build configurations. Creating and permissioning users would also be a nice-to have - but not so important.
Yegor Yarko
  Yegor Yarko
13 Sep 2010 21:45
20 months ago
Anthony,

Thank you for details. It seems that for now you can try to create a project with default settings that you would copy to create a new one.
Anthony Milbourne
  Anthony Milbourne
14 Sep 2010 12:34
20 months ago
Creating a new project by copying an existing project (or using a template) would be fine. Are you saying that we could do this without an API, or are you confirming that this functionality would be enough if there was an API?
Yegor Yarko
  Yegor Yarko
14 Sep 2010 13:11
20 months ago
Anthony,

Most probably you can copy the project now from an external script using "undocumented" way like the one described on the page. The actual URL and parameters can be looked up from the actual request browser sends to the server when you copy a project in UI.
However, since this is an undocumented way, it can be changed in any of the future TeamCity versions without any prior notice.
Anthony Milbourne
  Anthony Milbourne
14 Sep 2010 13:20
20 months ago
Thanks, we will look at this. However a proper API would be better :-)
Michael Kuzmin
  Michael Kuzmin
26 Jan 2011 19:44
15 months ago
Also requested in forum thread http://devnet.jetbrains.net/message/5284371
Michael Kuzmin
  Michael Kuzmin
10 Feb 2011 17:20
15 months ago
Request in forum to modify build trigger settings: http://devnet.jetbrains.net/message/5286034
Kevin Conaway
  Kevin Conaway
16 Feb 2011 22:46
15 months ago
Any updates here? Having a web service API to create projects and builds would do wonders for our organization
Michael Kuzmin
  Michael Kuzmin
24 Feb 2011 16:20
15 months ago
request to change VCS roots http://devnet.jetbrains.net/thread/292893
Stefan Brabec
  Stefan Brabec
14 Mar 2011 11:56
14 months ago
For us it would be helpful if SBuildType options (like BT_MAX_RUNNING_BUILDS) could be set via REST. This way we could e.g. customize our build configurations based on the working / non-working hour or weekend (e.g. we would like to trigger 8 long running configurations in parallel during the night but would limit those to 1 or even disable them during office hours). I recently tried the http way of triggering a build with agentId=allEnabledCompatible during midnight, but since BT_MAX_RUNNING_BUILDS is set to 2 it only uses two agents at a time (while all others are idle).
CG ex-Linden
  CG ex-Linden
20 May 2011 21:29
12 months ago
Being able to define build configurations via an API would be extremely useful for our organization. We use very standardized combinations of multi-platform builds with snapshot dependencies and also packaging builds aggregated into image builds, themselves aggregated into cluster builds, with very standard artifact dependencies and build completion triggers. Currently, setting up one of these is about a 30 minute exercise of mindless clicking and cutting/pasting. Yes, templates help, and yes, copying projects and configurations help, but you still need to then go through and manually adjust the VCS roots and the dependencies, over and over again.
CG ex-Linden
  CG ex-Linden
20 May 2011 21:31
12 months ago
If anyone has written a plugin for themselves and is willing to share...
Michael Kuzmin
  Michael Kuzmin
20 May 2011 21:50
12 months ago
Chris Walquist
  Chris Walquist
20 May 2011 23:08
12 months ago
I put up on github.com a prototype of a dead-simple plugin that manages checkout rules for a given build config (helps in one-step branching in our environment).

Lots of room to expand, of course, but it's a start. It's derived from the samplePlugin.zip in the devPackage that ships with TeamCity, and tested against 6.0.3.

https://github.com/walquis/teamcity-plugin-vcsrootmanager

Cheers,
  • chris
CG ex-Linden
  CG ex-Linden
24 May 2011 18:39
12 months ago
In it's simplest form, a plugin that would grab and release a lock on the actual project.xml files would be good enough to solve my problem. Is there any way to write that?
Yegor Yarko
  Yegor Yarko
24 May 2011 19:00
12 months ago
In it's simplest form, a plugin that would grab and release a lock on the actual project.xml files would be good enough to solve my problem

This is currently possible. No locks are exposed to the open API and so far it's not clear why we would need to do that. Can you describe why do you need the lock? It can be better to move this discussion into the forum as it seems to be a bit off the main issue.
CG ex-Linden
  CG ex-Linden
24 May 2011 19:32
12 months ago
I want to be able to safely modify the project.xml files while the TC master is running. I tried this in the past, and it caused all changes made via the web UI in the same project to be lost.
Yegor Yarko
  Yegor Yarko
24 May 2011 19:49
12 months ago
I tried this in the past, and it caused all changes made via the web UI in the same project to be lost.

Provided the changes are not made simultaneously, that should not be the case. If you can reproduce this, it can be investigated separately.
Basically, changing xml is about the same as changing the settings from web UI: if there is a concurrent change, the last change wins.

Oh, I see you've created a thread on this: http://devnet.jetbrains.net/message/5304150#5304150
Let's continue there.
Michael Kuzmin
  Michael Kuzmin
25 Aug 2011 20:47
9 months ago
Ricky Sheaves
  Ricky Sheaves
26 Aug 2011 00:25
9 months ago
(Thanks for linking in my thread above, Michael.)

That this isn't available is a real bummer. An API that would provide our automation scripts a means to create new projects and build configurations, as well as manipulate existing ones, is practically essential for my organization's needs. If this were available in the TeamCity product, I'd select it over CCNet right this minute. Unfortunately, since it is not in the product, the decision has become pained.

This request was made 2 years ago; is it seriously being considered for addition to the REST API?
Antoine Levy-Lambert
  Antoine Levy-Lambert
10 Sep 2011 01:05
8 months ago
The company where I am currently working needs this too. This is very useful to apply mass modifications or to setup CI for new branches.
Andrew Logvinov
  Andrew Logvinov
07 Oct 2011 12:31
7 months ago
I also vote up this ticket. A very useful feature.
Michael Kuzmin
  Michael Kuzmin
22 Nov 2011 15:16
6 months ago
request to pause build configurations from a build script
http://devnet.jetbrains.net/thread/430524
Yegor Yarko
  Yegor Yarko
07 Jan 2012 23:25
4 months ago
Hi guys!

I've added some build configuration editing functionality into the current TeamCity trunk (7.0).
What is available now:
  • empty project creation, empty build configurations, copying of projects and build configurations
  • build configuration editing except for template operations.
  • VCS roots creation and deletion, VCS root attaching with checkout rules, detaching from a build configuration

What is NOT available:
  • nothing about build configuration template (no editing, not even viewing) UPDATE: this is already available in EAP, build 21075
  • VCS root editing UPDATE: this will be available since build 21138 (not yet public)


TeamCity 7.0 release is planned very soon, within 6-8 weeks, so any early feedback on new REST API features is highly appreciated. If you do care about the functionality, please try it and let us know about any issues or thoughts. Posts to the forum and links here are welcome.

I am attaching current version of REST API plugin: rest-api_TW-8394_1.zip.
It should be compatible with the last TeamCity EAP, build 20939.
You can use the plugin in the latest EAP by copying the attached zip under .BuildServer\plugins
UPDATE: just use EAP build 21075

A tiny example of a step viewing and new creation:
curl -v --request GET http://user:pass@localhost:8111/app/rest/buildTypes/id:bt2/steps
curl -v --request GET http://user:pass@localhost:8111/app/rest/buildTypes/id:bt2/steps/RUNNER_1 -o response.xml
curl -v --request POST http://user:pass@localhost:8111/app/rest/buildTypes/id:bt2/steps --data-binary @response.xml --header "Content-Type: application/xml"

Build configuration copying:
curl -v --request POST http://user:pass@localhost:8111/app/rest/projects/id:project10/buildTypes --data "<newBuildTypeDescription name='Conf Name' sourceBuildTypeLocator='id:bt42' copyAllAssociatedSettings='true' shareVCSRoots='false'/>" --header "Content-Type: application/xml"

All the supported requests are listed in response to /app/rest/application.wadl request. You are also welcome to see not-so-pretty source code, if interested.
Andrew Logvinov
  Andrew Logvinov
11 Jan 2012 18:06
4 months ago
Great! My use-case (copy build configuration and modify its build parameters) can be successfully solved with this version.

I can also think of the following useful features:
  • modify build configuration name (based on <buildLocator>)
  • add/remove VCS root for build configuration (based on <buildLocator> and some <rootLocator> maybe)

And it would be great to have a bit more documentation too =)
Yegor Yarko
  Yegor Yarko
11 Jan 2012 22:28
4 months ago
modify build configuration name (based on <buildLocator>)

Available via: curl -v --request PUT http://user:pass@localhost:8111/app/rest/buildTypes/id:bt2/name --data "New name"

add/remove VCS root for build configuration

Available in the above-described manner via:
curl http://user:pass@localhost:8111/app/rest/buildTypes/id:bt778/vcs-root-entries
curl -v --request GET http://user:pass@localhost:8111/app/rest/buildTypes/id:bt778/vcs-root-entries/id:3 -o response.xml
curl -v --request DELETE http://user:pass@localhost:8111/app/rest/buildTypes/id:bt2/vcs-root-entries/id:3
curl -v --request POST http://user:pass@localhost:8111/app/rest/buildTypes/id:bt2/vcs-root-entries --data-binary @response.xml --header "Content-Type: application/xml"

And it would be great to have a bit more documentation too =)

I would appreciate details on what needs the explanation most.
http://user:pass@localhost:8111/app/rest/application.wadl should list all the available requests. XML schema for the used entities will also be available in the next EAP.

UPDATED (to match recent TeamCity EAP)
Michael Kuzmin
  Michael Kuzmin
11 Jan 2012 23:04
4 months ago
a request to disable/enable agents http://devnet.jetbrains.net/thread/433046
Воробьев Сергей
  Воробьев Сергей
17 Jan 2012 18:06
4 months ago
curl -v –request POST http://user:pass@localhost:8111/app/rest/buildTypes/id:bt2/vcs-roots –data-binary @response.xml –header "Content-Type: application/xml" don't work for me =(
My workflow:
1) curl -v –request GET http://user:pass@localhost:8111/app/rest/vcs-roots/id:1 -o response.xml
2) change name and id in response.xml
3) curl -v –request POST http://user:pass@localhost:8111/app/rest/buildTypes/id:bt2/vcs-roots –data-binary @response.xml –header "Content-Type: application/xml"
What wrong?

Also, I think
curl -v –request GET http://user:pass@localhost:8111/app/rest/buildTypes/id:bt778/vcs-roots/id:3 -o response.xml
should work like
curl -v –request GET http://user:pass@localhost:8111/app/rest/vcs-roots/id:3 -o response.xml

not like just cropped version of
curl -v –request GET http://user:pass@localhost:8111/app/rest/buildTypes/id:bt778/vcs-roots -o response.xml
Yegor Yarko
  Yegor Yarko
17 Jan 2012 19:06
4 months ago
Sergey,

If you use attached version of the plugin with the latest TeamCity EAP, I'd appreciate a separate issue on this not to pollute this one.

Please describe what does "don't work for me" mean exactly - what is the output, what is in teamcity-rest.log, etc.

Your suggestion about buildTypes/XX/vcs-roots/YY vs vcs-roots/YY is probably another issue. However, as the entities returned are different, so far I could not agree.
Воробьев Сергей
  Воробьев Сергей
17 Jan 2012 19:57
4 months ago
Yegor, I create issue for first case.
http://youtrack.jetbrains.net/issue/TW-19802?projectKey=TW

Second comment is just my opinion, feel free to ignore it.
John Foulkes
  John Foulkes
05 Feb 2012 02:27
3 months ago
I have found the method to create vcs roots in the XML schema with http://localhost:8111/httpAuth/app/rest/vcs-roots/ however there is not documentation on what to POST. Is it possible to create a detached vcs root, then attach to a project afterwards?
Yegor Yarko
  Yegor Yarko
07 Feb 2012 12:58
3 months ago
John,

The schema should also be available, see <grammars> tag at the beginning of application.wadl
e.g. try http://localhost:8111/httpAuth/app/rest/application.wadl/xsd1.xsd

You are supposed to POST the same XML that you get on GET for an existing VCS root. The logic as for all other entities. I've updated the doc a bit on this.

Is it possible to create a detached vcs root, then attach to a project afterwards?

Yes, that's how it works, search for "Attach VCS root to a build configuration" on the REST doc page.
John Foulkes
  John Foulkes
13 Feb 2012 18:53
3 months ago
Retrieving properties for VCS root is returning an error for me:

http://localhost:8111/httpAuth/app/rest/vcs-roots/id:2/properties/user

I vcs root 2 is a valid vcs root. I am doing a GET request. As per the documentation (GET/PUT http://teamcity:8111/httpAuth/app/rest/vcs-roots/<vcsRootLocator>/properties/<property_name>) I would expect this to return the value for the 'user' property for the vcs root. I am receiving:

Error has occurred during request processing (Not Found).
Error: com.sun.jersey.api.NotFoundException: null for uri: http://localhost:8111/app/rest/vcs-roots/id:2/properties/user
Please check URL is correct.
Yegor Yarko
  Yegor Yarko
13 Feb 2012 21:49
3 months ago
John,

Thank you for trying new additions to REST API. Could you please post a new issue or create a new forum thread so that we do not keep updating this issue?
Please include the build number that you are using and output of http://localhost:8111/app/rest/vcs-roots/id:2/properties request.
Jason Perry
  Jason Perry
13 Feb 2012 23:25
3 months ago
Is there a way to pause all build configurations using the rest api? I know how to get all the build configuration ids but was wondering if you could pause a build configuration using the rest api? The reason I ask is we have a test teamcity server where we test out the new versions with our currently running config files which have over 800 build configurations and when testing I don't want to have all the builds trigger. Do you guys have a recommendation on the best way to accomplish this? One idea I know of is to have one agent and just disable the agent but we are using EC2s on this test machine.

Thanks,
Jay
Yegor Yarko
  Yegor Yarko
14 Feb 2012 00:03
3 months ago
Jason,

In 7.0 you can PUT "false" to http://localhost:8111/app/rest/buildTypes/id:bt10/paused to pause a build configuration.
Also, in 7.0 in web UI you can move all the projects that you are not interested about in a separate agent pool with no agents.
Or make the connected agents compatible only with specific configurations on "Compatible Configurations" Agent tab.

Please post additional questions to the forum.
Jason Perry
  Jason Perry
14 Feb 2012 00:27
3 months ago
ah nice, I'll try the agent pool approach. Can we get a "select all" projects on the agent pool page? :)
Tony Esposito
  Tony Esposito
08 Mar 2012 00:14
2 months ago
Does anyone know if it is possible to send (POST) a command from an external (remote) program to TeamCity to start a build configuration? I would like to send a command via a program – any language – and start a build via the REST API or any other externally accessible API. Cheers!
Yegor Yarko
  Yegor Yarko
13 Mar 2012 15:29
2 months ago
Tony,

Triggering a build is not yet available via REST (TW-14941), but it can be done by doing the same request as user in web UI, see the documentation: http://confluence.jetbrains.net/display/TCD65/Accessing+Server+by+HTTP

BTW, please do not post generic questions here. The forum is a good place to ask questions, however.
Tony Esposito
  Tony Esposito
19 Mar 2012 18:51
2 months ago
Thank you Yegor for your response and assistance. And also thanks for the forum link – I will direct further questions there. Have a good day.