Passing an environment variable (parameter) to dependency project in TeamCity

前端 未结 2 1307
时光取名叫无心
时光取名叫无心 2021-01-04 02:42

I have a build chain with two projects: A is the root project, B depends on it. B has two dependencies configured: an artifact and a snapshot dependency. One build configura

相关标签:
2条回答
  • 2021-01-04 03:24

    Since TeamCity 9.0 it is possible to override the dependencies parameters by redefining them in the dependent build:

    reverse.dep.<btID>.<property name>
    
    0 讨论(0)
  • 2021-01-04 03:26

    For TeamCity 8 and below unfortunately the only way parameters can be passed on is in the direction of the build chain - the reverse of what you want - these properties are called Dependencies Properties:

    Dependencies Properties

    These are properties provided by the builds the current build depends on (via a snapshot or an artifact dependency).

    Dependencies properties have the following format:

    dep.<btID>.<property name>

    Dependencies properties flow from the root of the tree to its leaves (in the direction of the build chain flow) , but not the other way round, so the properties of A can be accessed in B.

    This is clarified in the docs here:

    Parameters in dependent builds

    TeamCity provides the ability to use properties provided by the builds the current build depends on (via a snapshot or artifact dependency). 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 the build chain flow and not vice versa. For the details on how to use parameters of the previous build in chain, refer to the Dependencies Properties page.

    I've had a similar use case for the reverse flow before as well - the workaround was not pretty - basically instead of triggering the build chain directly we would trigger an independent build (let's call it X) that was only there to hold the build parameters - then modify the build chain to have the root build (A in your case) depend on the last successful build of X and have the build chain trigger on a successful build of X - this should accomplish what you want.

    For TeamCity 9 see @Alina's answer (which should be the accepted answer).

    0 讨论(0)
提交回复
热议问题