Building the entire chain with the same set of parameter values

Hi,

I'm using TeamCity Professional 2022.10.1 and I'd like to build the entire chain with the same parameters and parameter values (specifically environment variables, defined with the env. prefix - I only want to use those across the board, if possible), regardless of which build configuration in the chain is triggered.

Let's say I have a chain Init -> Build -> Test -> Package -> Release. And parameters env.arch, env.build_type and env.channel that should have the same values across all builds in a chain.

I'd like to be able to trigger any of those build configurations (let's say Release, or Build), set env.arch, env.build_type and env.channel while triggering, by choosing from drop-downs of predefined values and have every build earlier in the chain use the same values.

It seems like the most basic, essential feature and I'm struggling to make it work. I found other posts about it here and elsewhere, but they're mostly pretty old and none of them made this clear to me.

My observarions so far:

* I tried defining the same set of parameters in all build configurations, with a prompt/select spec in Init and a value of %dep.MyProject_Init.env.paramName% in the other build configurations, thinking I'd be prompted when triggering, but I wasn't and the value was empty in Init.

* I tried setting reverse.dep.*.env.paramName to %env.paramName%, so that I could trigger, fill in env.paramName and have that propagated, but %env.paramName% is not resolved at the time of triggering and I got a literal %env.paramName% value in Init.

I don't want to duplicate every environment variable parameter in every build configuration as a regular configuration parameter and require users to enter every value twice, just so values get propagated through the chain.

I feel like I'm missing something obvious, because this can't possibly be this hard. Please explain how to build an entire chain with the same set of environment variable parameters.

Thanks

0
4 comments

For now I've rearranged things to get around the problem:

* moved the build configurations to subprojects for each architecture (will use templates) and set the env.arch parameter subproject-wide

* set env.build_type project-wide for now

* set env.channel in Init via a service message and set the parameter to dep.MyProject_Init.env.channel in Build/Test/Package/Release (it's too bad the value doesn't show up in the Parameters tab after being set, btw)

So I have something that works, but I'd still like to know the answer to the original question, because there will be cases where I'll want to set some value for the whole chain at the moment of triggering a build.

0
Hi Wojciech, and welcome to the forums.

Currently, TeamCity doesn't resolve parametrized values a reverse.dep parameters, it is a known limitation. Please feel free to track the request to implement the support for resolving parametrized values for reverse.dep parameters here: https://youtrack.jetbrains.com/issue/TW-42994.

In the meantime, as an alternative way of working around the limitation, you can add these parameters to your build configurations.

Build configuration: MyProject_Init
Parameter name: env.channel
Parameter value: %env.channel%

Build configurations: MyProject_Build, MyProject_Test , MyProject_Package, MyProject_Release
Parameter name: env.channel
Parameter value: %dep.MyProject_Init.env.channel%

Build configurations: MyProject_Build, MyProject_Test , MyProject_Package, MyProject_Release
Parameter name: reverse.dep.MyProject_Init.env.channel
Parameter value:
Parameter spec: select display='prompt' data_2='yourSelectableOption1' data_1='yourSelectableOption2' data_3='yourSelectableOption3'

I hope that helps!
0

Hi Anatoly Cherenkov,

Thanks a lot for the advice.

I did as you suggested and:

  • Defined all the chain-wide parameters in Init, with real static default values (or set values via setParameter at runtime in Init)
  • In Build, Test, Package and Release, defined all the chain-wide parameters with defaults referencing parameters from Init via %dep.MyProject_Init.env.param_name%
  • For chain-wide parameters that should be settable when triggering a build, defined reverse.dep.MyProject_Init.env.param_name for each in Build, Test, Package and Release
  • Set the build number format to %dep.MyProject_Init.env.build_name%:%build.counter% in Build, Test, Package and Release (and set env.build_name in Init to the output of `git describe --always --tags "%build.vcs.number%"` via setParameter), so I have a consistent name throughout the chain, with individual counters per build configuration

This appears to work as intended, but comes at the price of a lot of redundancy.

If I want to set some parameter while triggering any of the builds in the chain, I need to define the same parameter spec for it in every build configuration.

In case of parameters I want to propagate through the chain, but not set when triggering Build, Test, Package, or Release, I can simplify the spec down to "not empty / read-only", because the values from Init are guaranteed to meet the spec in Init, but it's still pretty awkward.

Definitely looking forward to this being simplified.

Thanks again!

0

Hi! If you don't need to refer to your parameter in TeamCity configuration (e.g. reference it in a build step settings), and just need to pass an environment variable to all the upstream builds, you can just set the reverse.dep.*.env.param_name parameter. But the value cannot be a parameter reference (see https://youtrack.jetbrains.com/issue/TW-42994).

0

Please sign in to leave a comment.