I have two branches in git: master and "deploy" (not the real name but good for this example. When I want to deploy things to the test server, I merge those changes into deploy branch and I want TC to automatically deploy them. So I have a Build and a Deploy config set up in TeamCity. Build is set up to build all branches, so commits in both branches trigger builds. I want to set up the Deploy config to run only after a successful Build, and only if that Build was against the deploy branch. I see that I can set up a Snapshot Dependency, which seems like what I want, but I can't figure out how to limit it to only that branch. I want to guarantee that the Deploy build runs against the same source as the Build for the deploy branch.
Asked
Active
Viewed 608 times
1 Answers
0
You can limit your builds to the deploy
branch via the the VCS Root configuration screen.
- Clear the Default branch field.
- Add the
refs/heads/deploy
branch to the Branch specification field.
In order to integrate this change with a build template, you can parameterize the Branch specification as %git.branch.specification%
.
- For branch builds, the value is set to
refs/heads/*
- For deploy builds, the value is set to
refs/heads/deploy

John Hoerr
- 7,955
- 2
- 30
- 40
-
The dependent deploy build has no VCS root. I want it to use the same checkout dir as the build which does the actual source building. – RationalGeek Feb 23 '14 at 14:42
-
If you tie everything to a build template, you can have your cake and eat it too. The 'deploy' configuration can just build and deploy the branch on its own. – John Hoerr Feb 23 '14 at 14:46
-
I get what you're saying. Trying to find a way where I don't do the build twice. But yeah this would probably work. – RationalGeek Feb 23 '14 at 14:52
-
Yeah, that might be possible with a little tinkering. You might be able to tell the 'branch' config to exclude the 'deploy' branch by specifying `-:refs/heads/deploy`. Our team is still figuring out how to tweak this sort of thing. – John Hoerr Feb 23 '14 at 14:57
-
Any joy with this kind of thing? I have a similar issue I'd like to resolve - http://stackoverflow.com/questions/22333809/teamcity-build-dependencies-and-choosing-the-correct-branch – Tim Peel Mar 11 '14 at 19:17