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?
You can associate/attach any number of existing build configurations with/to a template: there is the Attach to template option available from the Actions button in the upper right corner of the screen.
In Build Steps, click Auto-detect build steps, and then select the proposed steps you want to add to the current build configuration. You can change their settings afterwards. When scanning the repository, TeamCity progressively searches for project files on the two highest levels of the source tree.
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
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With