6
votes

I really can't get my head around the concept of snapshot dependencies in teamcity (7.1).

We have a build project which deploys the database accordingly to a build parameter (database name and file) and i have a build project which builds and deploys our web app.

What I would like to do now is to chain these two builds but override the build parameter. I found the manual how to access depency build parameters (%dep.btXX.yyy%) but i don't want to access them, i want to override them!

How can I achieve this? I've created a new build in which i trigger the build & deploy and then the database build but it completly ignores my dependency parameters and also I can't change the order of the builds.

Thanks for help!

2
You're talking about a reverse build parameter dependency? Ie; Build X depends on Build B, so you want a parameter specified for X to be available to B? I'd like to do that for checkout rules, to make sure the correct branch is built. If I find out how, I'll post it here..keithl8041
I presume you want the order to be: deploy database and then build and deploy the web app? When you say override the build parameter, where is the value coming from? Is it something you manually want to enter into the TeamCity GUI or is it something you would like to programmatically override?Andrew Fraser
You can use the TeamCity API to kickoff builds with certain parameters. I think you could get the desired functionality using that.lyoung

2 Answers

0
votes

Update: This answer is only relevant to TeamCity v8 or older

I have tried this myself but sadly I suspect it's not currently possible.

The Build Dependencies Setup documentation supports this:

When build A depends on build B, you can pass properties from build B to build A, i.e. properties can be passed only in the direction of build chain flow and not vice versa.

The (generally sensible) reason I think its like this is because of the following:

  • The dependent build configuration could be a dependency of more than one other build configuration.

Think about it: If two parents want to pass their (differing) parameters to the dependent build, what do they get for the "last successful build"? Theoretically TeamCity could check if the properties for the last build match what was needed (rebuilding otherwise). But even then you would end up with an ugly build history of builds for all different environments. This really doesn't fit with the concept of build configurations.

The best way to reuse the build configurations is to template them, and then create multiple projects setting properties at the project-level so they are available to all the contained build configurations.

Ultimately the best advice may be to reconsider if you really need to use two build configurations for your project at all. Best-practice is to minimize the number of build configurations and build steps - put as much build logic into your own scripts as possible.

8
votes

According to the documentation, it's now possible in Teamcity 9:

Overriding Dependencies Properties

Since TeamCity 9.0, there is a possibility to override the dependencies parameters by redefining them in the dependent build. For example, build configuration A depends on B and B depends on C; A has the ability to change parameters in any of its dependencies using the following format: reverse.dep..

It is also possible to change parameter in all dependencies at once: reverse.dep.*.

The dependencies properties to be overridden can be specified in the parameter names of the dependent build A, either in the custom build dialog or via build configuration parameters.

Pushing a new parameter into the build will supersede the "Do not run new build if there is a suitable one" snapshot dependency option and may trigger a new build if the parameter is set to a non-default value.