I'm trying to access the branch name in Cake on TeamCity running inside a Linux Docker container, but whenever I try to fetch any of the "Configuration Parameters", the values are returning nothing.
In my branch, the following build parameter values are visible on TeamCity:
Configuration parameters
- vcsroot.branch: refs/heads/master
- teamcity.build.branch: 5/merge
Environment variables
- env.vcsroot.branch: 5/merge
The env.vcsroot.branch
variable has a value of %teamcity.build.branch%
.
My cake script simply tries to spit out the values, and all of the ones below are coming back empty:
var branch = EnvironmentVariable("vcsroot.branch");
var tcbranch = EnvironmentVariable("teamcity.build.branch");
var agent = EnvironmentVariable("system.agent.name");
var confName = EnvironmentVariable("system.teamcity.buildConfName");
var buildId = EnvironmentVariable("teamcity.build.id");
var vcsRootBranch = EnvironmentVariable("vcsroot.Root_TemplatedVcsRoot1.branch");
var argOrEnv = ArgumentOrEnvironmentVariable("teamcity.build.branch", "vcsroot.branch", "Unfound");
Information($"vcsroot.branch = {branch}");
Information($"teamcity.build.branch = {tcbranch}");
Information($"system agent name = {agent}");
Information($"system TC build cof name= {confName}");
Information($"param buildId = {buildId}");
Information($"vcsroot template branch = {vcsRootBranch}");
Information($"test argument or env variables = {argOrEnv}");
The actual output:
[12:34:51][Step 1/2] vcsroot.branch =
[12:34:51][Step 1/2] teamcity.build.branch =
[12:34:51][Step 1/2] system agent name =
[12:34:51][Step 1/2] system TC build cof name=
[12:34:51][Step 1/2] param buildId =
[12:34:51][Step 1/2] vcsroot template branch =
[12:34:51][Step 1/2] test argument or env variables = Unfound
Oddly enough, on our non-docker Windows-based TeamCity agents, the values seem to return fine. I have a feeling I'm missing something here that's painfully simple, but I'm a relative novice when it comes to Cake, TeamCity, and Docker. Any help would be greatly appreciated. Thanks!
Edit: to claify, most of the environment variables are coming back as expected; the only one that I've noticed that doesn't is the one that references a configuration parameter.