9

How do I change the build configuration template for a project?

Previously my TeamCity project was using a generic build template which is used by 5 other projects. I created a new template by copying an existing template and made changes that are relevant to my project. Now I cannot find a way to using this template in my TeamCity project.

Is there a easier way other than creating a new build configuration and inheriting the newly created build template?

Wai Ha Lee
  • 8,598
  • 83
  • 57
  • 92
joe
  • 311
  • 1
  • 3
  • 10

2 Answers2

14

Following is mentioned in TeamCity doc:

  • You can create new build configurations based on a template.
  • You can associate any number of existing build configurations with a template: there's the Associate with Template option available from the Actions button at top right corner of the screen.

So, Option 1 you have is to to go through each Build Configuration, detach from old template and attach to the new one.

Option 2 you might want to consider will be to modify your existing template with the new settings instead of creating a copy. This might be suitable if you are only planning on using one template.

Option 3 is to use TeamCity API which allows to read, detach and attach a build configuration from/to a template:

GET/DELETE/PUT http://teamcity:8111/httpAuth/app/rest/buildTypes/<buildTypeLocator>/template
Rod
  • 1,443
  • 15
  • 17
3

There is an option 4: If you have the settings in a git-repo, then you can checkout that git-repo, search and replace all ref occurrences of the template-id with new template-id found in

<settings ref="old-template-id">

Then commit and push the new xml files to teamcity repo.

After around 3-4 minutes, the new configuration is applied by teamcity automatically

Rainer
  • 803
  • 10
  • 8
  • Awesome! As I had access to the teamcity directories, I just changed it in the config files located in /config/projects/[ProjectName]/buildTypes/[BuildConfigName].xml – Daniel Z. Feb 26 '19 at 13:36