5
votes

I've set up top-level project A in TeamCity.

Project A has one build configuration called A1.

Project B is a subproject of A.

Project B has one build configuration called B1.

In this build configuration, I defined two parameters:

  • env.param1 = "ABCDE"
  • env.param2 = %param1%

Then, from project B's build configuration (B1), I extract a meta-runner and attach it to B's parent project A.

But when I then I try to use the meta-runner in project A's build configuration (A1), this build won't run; it complains that env.param1 is not defined.

When I look in the definition of the build step (A1) or meta-runner, I can plainly see that env.param1 is defined within. But on project A's build configuration (A1) parameters page, it lists env.param1 as "".

I thought that a meta-runner more or less encapsulates everything defined within it so it can be used anywhere you attach it. From the docs:

Basically, a meta-runner is a set of build steps from one build configuration that you can reuse in another; it is an xml definition containing build steps, requirements and parameters that you can utilize in xml definitions of other build configurations. TeamCity allows extracting meta-runners using the web UI.

[Snip]

Upon clicking the Extract button, TeamCity will take definitions of all build steps and parameters in this build configuration and create a build runner out of them.

What am I doing wrong?

1
The problem is actually more general than this. It appears that any meta-runner does not have access to build parameters outside itself. To work around this, you can add parameters to the metarunner, which then are set each time it's used from parameters of the builds which use it.Dan Fitch

1 Answers

1
votes

The metarunner is looking at your env.param1 in project A, which is "". To avoid this, use a metarunner-specific variable within the metarunner, and define that in the metarunner's build step. This way, there won't be any confusion.

If you want to parameterize things automatically, you can set the metarunner-specific variable in the build step to reference project A's %env.param1%.