Question

I'm using teamcity 8.x.x version.I configured my Teamcity for continuous deployment. I'm need a feature branching deployment. I see this document "http://confluence.jetbrains.com/display/TCD8/Working+with+Feature+Branches".

I'm trying this document implementing on my Teamcity. I have a problem.

My deployment config use "OctoPack" (nuget). My nuget package needs build count and branch name. example: 1.0.0.356-feature-1.

I'm try this versioning,

%build.number%-%teamcity.build.vcs.branch.VCS_ROOT_ID% ----> 1.0.0.356-refs/head/feature-1

this version not support nuget versioning. nuget not comparative "/".

I need this,

%build.number%-%teamcity.build.vcs.SHORT_BRANCH_NAME.VCS_ROOT_ID% ---> 1.0.0.356-feature-1

how can I ?

Thanks

Was it helpful?

Solution

I believe what you need is another variable. Try using %vcsroot.branch%. There is also %teamcity.build.branch%, but that one will contain "<default>" on the default branch. If you want more flexibility to choose exactly which part of the branch name gets selected, you can follow the instructions on this page:

http://confluence.jetbrains.com/display/TCD7/Working+with+Feature+Branches#WorkingwithFeatureBranches-branchSpec.

OTHER TIPS

I found that if you have one branch set up in the VCS, then %teamcity.build.branch% is not defined. And if you have multiple branches defined, then %vcsroot.branch% only reports on the the name of the default branch.

I ended up using a git command to give the current branch name.

Powershell:

$branch = (git symbolic-ref --short HEAD) | Out-String

Command Line:

FOR /F "tokens=* USEBACKQ" %%%%F IN (`git symbolic-ref --short HEAD`) DO (
SET branchName=%%%%F
)
ECHO %%branchName%%

TeamCity converts all %% -> % so that's why there are so many %

Set as environment variable

If you would like to use the branch name as an environment variable to be used in other steps of your project you can set the branch name by using Powershell as an example. First define env.currentBranch in your build configuration and then set it with the following powershell as your first build step.

$branch = (git symbolic-ref --short HEAD) | Out-String
Write-Host "##teamcity[setParameter name='env.currentBranch' value='$branch']"
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top