GitFlow branch naming

Hi

We're using TeamCity with Octopus Deploy and would like to use the GitFlow branch in the package name so that we can configure Octopus channels to deploy feature branches into dev.

The '/' in the fully qualified branch name prevents NuGet from successfully packaging and I was wondering how others have managed to get around this? Not done much so far with custom build scripts but I imagine this is going to be the approach?

Thanks!

1
3 comments

Looks like I'm facing the same problem. Any chance you found a good solution?

Best I've found is to create multiple build configurations which seems overkill and a maintainability problem for my small team.

1

Hi,

While I'm unfamiliar with GitFlow branch naming, once you set up the branch specification in the VCS Root, something like +:refs/heads/my_branch, you can add parenthesis to some (or all) and that will be turned into the "logical branch name", which you can later use via the parameter %teamcity.build.branch%. In this case: "+:refs/heads/(my_branch)" would yield "my_branch" as the parameter. Alternatively, you can have something like "refs/heads/*" and then everything matched by the "*" will be used as the branch name.

If you still have the "/"s on the branch name, because they are also included in later parts of the name, then I'm afraid you will need to script your way around it. The easiest way would be to create a build parameter at the build configuration level, something like %my_package_name%, make it empty, and then on your first build step, add a script that will replace the "/" for something like an underscore, or any other safe symbol . Then you can reference %my_package_name% throughout the build to have access to the new value. Modifying the parameter for the build from within a script can be done through service messages: https://confluence.jetbrains.com/display/TCD10/Build+Script+Interaction+with+TeamCity#BuildScriptInteractionwithTeamCity-changingBuildParameterAddingorChangingaBuildParameterfromaBuildStepAddingorChangingaBuildParameter

Note that modifying this parameter for a build will only modify it in the scope of its build, it will not change it in the build configuration.

Hope this helps.

0

I pretty much did what you suggested.

Wrapped the part of the path I wanted in braces to capture it, then added a build parameter and a script for converting the teamcity.build.branch into something that will work as the tag in a package name.

Thanks for your help.

0

Please sign in to leave a comment.