Gitflow branches

Hi,

One of our development teams is using Git and Gitflow with Continua. Gitflow branches are formatted ‘feature/feature1’, ‘feature/feature2’ and accessible through the property $Build.BranchName$.

However, our builds are stored on a networkshare and we’re using the branchname as subfolder. Since Gitflow branches contain a slash (’/’) character, this will actually lead into another subdirectory when using a gitflow branch name in a pathname.

e.g. Output path: \server\share\releases$Build.version$.$Build.BranchName$ will lead to different paths (and path depths) for master branch and feature branches:

\server\share\releases\1.0.0.master…
\server\share\releases\1.0.1.master…
\server\share\releases\1.0.0.feature\feature1…

Looking for advice/smart solution in this matter. We can always get rid of Gitflow or change the feature structure, but probably would be better to solve this another way. We haven’t found any “Continua way” solution yet. Within variables or properties you cannot regex or replace strings/characters (as far as I am concerned). “set variable” allows replacement of variables, but this is merely a rewrite. Even though you can append, you cannot replace.

Kind regards,
Remko Seelig

Hi Remko,

We may add string manipulation functions in the future. For now, you will need to do this using FinalBuilder project, batch file, Powershell script or another external program. A FinalBuilder project with String Replace and Continua CI - Set Variable actions would be the simpliest to manage.

Alternatively you can use the following example PowerShell script:

param(
    [Parameter(Mandatory = $true)] [string]$variableName,
    [string]$text = “”
)
[string]$result = $text.Replace("/","_")
write-host "@@continua[setVariable name=’$variableName’ value=’$result’ ]"

and pass this the arguments

 “branchFolder” “$Source.RepoName.BranchName$” 

where branchFolder is the name of a variable defined in Continua CI


This was exactly what I was looking for. Works like a charm. Thank you very much!

@Remko: we use GitFlow everywhere as well. A few (possibly) interesting projects for you:

* GitVersion => automatically determine the version (based on GitFlow) for your software
* ContinuaInit (see http://geertvanhorrik.com/2014/06/17/introducing-continuainit-initialize-build-server-variables/)

This way you can have an initialization stage where everything is prepared for the builds. If you define these variables, they will be filled for you automatically:

GitVersion_FullSemVer
GitVersion_MajorMinorPatch
GitVersion_NuGetVersion
IsOfficialBuild
PublishType

Then you can use this versioning to stamp your assembly info, nuget packages, etc.