Create, Move, and Delete Build Configurations
This article shows how to create, pause, and delete build configurations via TeamCity REST API.
To create a new build configuration, compose and post a BuildType entity to:
POST/app/rest/buildTypes
Example:
<buildType description="string" id="string" name="string">
<project id="MyProjectID"/>
<templates>
<buildType id="MyTemplateID"/>
</templates>
<parameters>
<property name="myBuildParameter" value="myValue"/>
</parameters>
<steps>
<step name="myCommandLineStep" type="simpleRunner">
<properties count="4">
<property name="script.content" value="echo 'Hello World!'"/>
</properties>
</step>
</steps>
</buildType>
{
"id": "id",
"name": "name",
"project": {
"id": "MyProjectID"
},
"templates": {
"buildType": [
{
"id": "MyTemplateID"
}
]
},
"parameters": {
"property": [
{
"name": "myBuildParameter",
"value": "myValue"
}
]
},
"steps": {
"step": [
{
"name": "myCommandLineStep",
"type": "simpleRunner",
"properties": {
"property": [
{
"name": "script.content",
"value": "echo 'Hello World!'"
}
]
}
}
]
}
}
To copy a build configuration to the same or a different project, compose and post a NewBuildTypeDescription entity to:
POST/app/rest/projects/<TargetProjectLocator>/buildTypes
TargetProjectLocator
— a ProjectLocator that specifies which project should own the new copy of a build configuration.Request body — a new NewBuildTypeDescription entity, where:
sourceBuildTypeLocator
— a BuildTypeLocator that specifies which build configuration should be copied;name
,id
— String name and ID for the new copy of the build configuration;copyAllAssociatedSettings
— set totrue
.
Example:
<newBuildTypeDescription copyAllAssociatedSettings="true" id="Source_Config_ID_Copy1" name="Source_Config_Name_Copy1" sourceBuildTypeLocator="id:Source_Config_ID" />
{
"sourceBuildTypeLocator": "id:Source_Config_ID",
"name": "Source_Config_Name_Copy1",
"id": "Source_Config_ID_Copy1",
"copyAllAssociatedSettings": true
}
To remove a build configuration from its original parent project and add it to another project, send a POST
request to the following endpoint:
POST/app/rest/buildTypes/<BuildTypeLocator>/move?<Target_ProjectLocator>
For example, the following request finds a build configuration with the "SourceProject_MyBuildConfig" ID and moves it to "MyProject2":
POSThttp://localhost:8111/app/rest/buildTypes/id:SourceProject_MyBuildConfig/move?targetProjectId=MyProject2
To delete a build configuration, send:
DELETE/app/rest/buildTypes/{buildConfigurationLocator}
where buildConfigurationLocator
is a BuildTypeLocator-typed string used to locate the build configuration.
To get the current status of a build configuration, use:
GET/app/rest/buildTypes/<buildTypeLocator>/paused
The server will respond with the text/plain
boolean value indicating whether the configuration is paused (true
) or not (false
). To change the status, put the required value in text/plain
format to:
PUT/app/rest/buildTypes/<buildTypeLocator>/paused
Thanks for your feedback!