Frage

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

War es hilfreich?

Lösung

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

Andere Tipps

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.

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).

Well, you can refer to this for starters:

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top