Please consider editing your post and mark it as obsolete instead. Do you want to delete post?
build parameters
Permanently deleted user
Created
I have two configurations, A and B. I have "teamcity.build.branch" available in A. I want the value of this variable in configuration B. How can I do it ?
If you have a snapshot dependency with B depending on A you can access the parameters of A via dep.<A's Build configuration ID>. so in your case something like %dep.Project1_A.teamcity.build.branch%
Thank you. I dont have any dependencies, is there still a way to do this. The two build configurations, A and B are in the same project. I am a teamcity 9.0.2 user.
Adding a snapshot dependency to B on A and use the method I suggested is likely the easiest solution. Assuming that every build of B should be referencing a build of A, this is part of what a snapshot dependency does. If not then things are more complicated, and you will need a true TeamCity master. One could do it without a dependency via some sort of integration, but I don't have much experience with TC integration and can see a solution of the top of my head.
There might be a YouTube video on this feature, but I will leave that reference to a more official JetBrains person.
@Priyashapratik: You need dependencies to use dependency parameters, although artifact dependencies work fine, it's not needed to have snapshot dependencies. Dependency parameters aren't pulled from the build configuration itself, but from the results of specific builds, so builds are needed to pick them up. A snapshot dependency will pick up the builds from the build ran or selected by the dependency. An Artifact dependency will pick up the parameters from the build from which the artifact was picked.
If this isn't a possibility for you, then it seems that you don't really want dependency parameters, but shared parameters for two build configurations. If that's the case, you should be able to simply set the parameter at the project level, and both builds will inherit the same value, so you would be able to use it.
Thank you so much @Chris Lusena and @Denis Lapuente. I am also thinking, can I exploit environment parameters to get the variables from one configuration to another ?
Yes, environment variables are usually set up in teamcity via "env.XXX parameters", and are equally accessible through dependency parameters. Setting up environment variables and accessing them without referencing the dependencies might not work. Build configurations aren't guaranteed to run in the same agent or process.
If you have a snapshot dependency with B depending on A you can access the parameters of A via dep.<A's Build configuration ID>. so in your case something like %dep.Project1_A.teamcity.build.branch%
See https://confluence.jetbrains.com/display/TCD10/Dependent+Build
Hope this helps.
--
Chris
Thank you. I dont have any dependencies, is there still a way to do this. The two build configurations, A and B are in the same project. I am a teamcity 9.0.2 user.
The need features appear to be available in TC9. I am a TC 2017 user.
https://confluence.jetbrains.com/display/TCD9/Dependent+Build
Adding a snapshot dependency to B on A and use the method I suggested is likely the easiest solution. Assuming that every build of B should be referencing a build of A, this is part of what a snapshot dependency does. If not then things are more complicated, and you will need a true TeamCity master. One could do it without a dependency via some sort of integration, but I don't have much experience with TC integration and can see a solution of the top of my head.
There might be a YouTube video on this feature, but I will leave that reference to a more official JetBrains person.
Hope this helps.
Hi,
thanks for the help, Chris!
@Priyashapratik: You need dependencies to use dependency parameters, although artifact dependencies work fine, it's not needed to have snapshot dependencies. Dependency parameters aren't pulled from the build configuration itself, but from the results of specific builds, so builds are needed to pick them up. A snapshot dependency will pick up the builds from the build ran or selected by the dependency. An Artifact dependency will pick up the parameters from the build from which the artifact was picked.
If this isn't a possibility for you, then it seems that you don't really want dependency parameters, but shared parameters for two build configurations. If that's the case, you should be able to simply set the parameter at the project level, and both builds will inherit the same value, so you would be able to use it.
Hope this helps.
Thank you so much @Chris Lusena and @Denis Lapuente. I am also thinking, can I exploit environment parameters to get the variables from one configuration to another ?
Yes, environment variables are usually set up in teamcity via "env.XXX parameters", and are equally accessible through dependency parameters. Setting up environment variables and accessing them without referencing the dependencies might not work. Build configurations aren't guaranteed to run in the same agent or process.