Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Creating Build Configuration via REST in Teamcity

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

like image 305
Jeevi Avatar asked Oct 07 '22 01:10

Jeevi


People also ask

How do I create a build configuration in TeamCity?

Go to Administration | Projects and open the required project. Alternatively, open the project using the Projects pop-up menu and click Edit Project Settings. The Project Settings page will open. On the Project Settings page, click Create build configuration under the Build Configurations section.

How do I use REST API on TeamCity?

You can start working with the REST API by opening the http://<TeamCity Server host>:<port>/app/rest/server URL in your browser: this page gives several pointers to explore the API. To learn more, proceed to the dedicated TeamCity REST API Help. Was this page helpful?

How do I use custom build in TeamCity?

To run a custom build with specific changes, open the build results page, go to the Changes tab, expand the required change, click the Run build with this change, and proceed with the options in the Run Custom Build dialog. Use HTTP request or REST API request to TeamCity to trigger a build.


2 Answers

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
like image 151
Kuberchaun Avatar answered Oct 13 '22 11:10

Kuberchaun


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.

like image 45
Mohammad Nadeem Avatar answered Oct 13 '22 11:10

Mohammad Nadeem