0

I want to have part of my destination path in build.cake be based on the branch being built. The top of my build.cake script says:

var branch = Argument("branch", "Master");

and I modified my Team City Build step to include

.\build.ps1 ... -Branch %teamcity.build.branch% 

but Team City complains that I have no eligible agents

Implicit requirements: teamcity.build.branch defined in Build step: Build

I'm new to TC and Cake so I'm likely missing something obvious. How do I hook this up?

Chris Nelson
  • 3,519
  • 7
  • 40
  • 51

1 Answers1

1

You are correct that %teamcity.build.branch% will give access to your branch name. However, this variable is blank unless you have a branch specification in your VCS root settings. In order to use say master as your build.branch parameter you need to add: +:refs/heads/(master) to your branch specification. Whatever is in between the parens will be put in the build.branch variable. If you might be building from multiple branches, you might have something like the following:

+:refs/heads/Release/(765/1.0)
+:refs/heads/Release/*

This would give your build.branch the name of branch as it appears in git after the Release/.

Also see Johan's answer: https://stackoverflow.com/a/27829516/6222375

  • Thanks. I don't see a "branch" specification. On the VCS Root page in the General Settings section, Default Branch was set to "refs/heads/myBranchName". Changing that top "+:refs/heads/(myBranchName)" causes the connection test to fail. (I'm using Git, if that matters.) I'll check the other answer and see if I can get it to work. – Chris Nelson Apr 05 '18 at 20:52
  • Click `Show Advanced Options` at the bottom of the VCS Root page. The `branch specification` will be under the `Default Branch` box. – TheEternalRat Apr 06 '18 at 21:29