Change build template in TeamCity
Asked Answered
S

2

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?

Sarcoma answered 7/9, 2015 at 12:15 Comment(0)
K
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
Khalid answered 7/9, 2015 at 23:23 Comment(1)
I think you mean "Hidden" not mentioned. Ta btw.Doghouse
I
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

Insight answered 24/8, 2018 at 13:43 Comment(1)
Awesome! As I had access to the teamcity directories, I just changed it in the config files located in /config/projects/[ProjectName]/buildTypes/[BuildConfigName].xmlSokoto

© 2022 - 2024 — McMap. All rights reserved.