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

大兔子大兔子 提交于 2019-11-30 22:32:27

问题


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 configuration for B has an environment variable (parameter) set. However, I also need this parameter set for the root project A.

Is there any way in TeamCity 9 to pass a build configuration parameter from a project to its dependency (in the same build chain)?


回答1:


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

reverse.dep.<btID>.<property name>



回答2:


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).



来源:https://stackoverflow.com/questions/28822099/passing-an-environment-variable-parameter-to-dependency-project-in-teamcity

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!