Configuration parameters of parent build in child build configuration

Hi,


I have two build configurations(A & B). A is dependent on B (In Build configuration A a snapshot dependency with build configuration B is created.)

Let's say A as parent build configuration and B as child build configuration. Whenever user runs A, teamcity will first run B and once it is completed A will run.

I know that we can get "B" configuration parameters in A using %dep.<btid>.properties.

Can you please let me know how to get A configuration parameters in build configuration B?

Regards,
Dayakar

5 comments
Comment actions Permalink

Hi Dayakar,

Won't it be an option to use Project Level Build Parameters?
Also we have the related feature request https://youtrack.jetbrains.com/issue/TW-5033, please watch/vote for it.

Message was edited by: Alina Mishina

0
Comment actions Permalink

Hi Alina,

My case is that I have couple of three configurations say A, B and C. C is common configuration. A is dependent on C. Also, B is dependent on C. A and B are not related.

User has choice to run A or B build configurations. In any of this case I want C should run first before A/B. Therefore, I have created snapshot dependency of C in both A and B configurations.(i.e A->C & B->C).

Now I have a build steps in C configuration which should get executed differently based on configurations(A&B). I mean need to execute different commands(in C) if build configuration C is invoked by Configuration A otherwise different commands(in C) if build configuration C is invoked by Configuration B.

Is there anyway to identify my parent(A or B) from clild(C)?

I am not if I can use project level build attributes to acheive the above because in case, the user wants to share the configuration parameters among all his build configurations then I believe Project level attributes are best suited. BUT, What if  I want to update the project level build parameters in other configurations? Is it allowed?

Regards,
Dayakar

0
Comment actions Permalink

Hi Dayakar,

I would recommend you to split build configuration C for two different build configurations: C1 and C2. And create two independent build chains: A -> C1 and B -> C2. You can use templates for C1/C2.
It is not a good practice to change the logic of build inside build script. In this case it will be difficult to interpret the results of the build and also the statistics of the builds (for example average build time) will be uninformative.

0
Comment actions Permalink

Hi Alina,

As an example I said A&B configurations but I have seven configurations which depend on build configuration C.

I already thought of this option but the overhead is that I have to create seven configurations(C1 -C7).

I was just wondering why does teamcity have no option of determining from child("C") which configuration(Aor B) has invoked him.

Regards,
Dayakar

0
Comment actions Permalink

Hi Dayakar,

The build server should answer the question "when to run a build" and build script - "what to run". It seems that in your case it would be better not to extract the build configuration C at all. For example you will have three target in your build script: targetA, targetB and targetC. In build configuration A you will run targetA, which will invoke targetC with needed parameters and so on.

On the other hand, you can use teamcity.build.triggeredBy parameter to define who triggered the build C. But it is not a recommended approach.

0

Please sign in to leave a comment.