5

Is it possible to create a new build configuration for an existing project via REST api(POST method) in Teamcity?
If so, how to create? (some guidelines )

Thanks

2
  • Hey, have you managed to do this? If yes, could you please show and explain an example? Commented Aug 9, 2013 at 11:45
  • Hi.. whatEver given as answer by Arpit has all the required Rest api.. u can refer to it. Commented Aug 12, 2013 at 7:13

3 Answers 3

4

It's for sure possible on 8.x, haven't the need to care about early versions.

Here's a really simple python snippet that will copy an existing build config into a given project using this as a guide http://confluence.jetbrains.com/display/TCD8/REST+API#RESTAPI-BuildConfigurationAndTemplateSettings.

import requests

xml =  """<newBuildTypeDescription name='NewBuildConfigName'
          sourceBuildTypeLocator='ExistingBuildConfigNameThatYouWantToCopy'
          copyAllAssociatedSettings='true' shareVCSRoots='false'/>
       """
headers = {'Content-Type': 'application/xml'} # set what your server accepts

print requests.post('http://YOURTEAMCITYWEBADDRESS:YOURTEAMCITYPORT/httpAuth/app/rest/projects/id:PROJECTIDWHERENEWBUILDCONFIGSHOULDBECREATED/buildTypes', data=xml, headers=headers, auth=('TeamCityUserName','TeamCityPassword')).text
Sign up to request clarification or add additional context in comments.

Comments

3

Its now possible in 8.x REST. You can do something like:

POST plain text (name) to http://teamcity:8111/httpAuth/app/rest/projects/<projectLocator>/buildTypes

Above is copied from 8.x REST. Check 8.x REST for more details.

Comments

2

No, it's not implemented in the REST API. Have a look at this

There is no way to create a build configuration. You can add build steps to it and configure them, but it doesn't seem to be implemented in the API at all. I was actually fighting with this myself last night. If you find a way to do it, please let me know.

Also, you could have a look at these notes I've put together concerning the Teamcity REST API. (Not that they're answering this question, but some of them could be quite useful).

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.