Skip to content

Instantly share code, notes, and snippets.

@wurmr
Last active December 18, 2015 12:28
Show Gist options
  • Save wurmr/5782746 to your computer and use it in GitHub Desktop.
Save wurmr/5782746 to your computer and use it in GitHub Desktop.
Powershell Script for Team City to extract a clean branch name for a repo using git flow
$long_branch_name = "%teamcity.build.branch%"
# Branch Name
if ($long_branch_name.Contains("develop") -or $long_branch_name.Contains("feature"))
{
$clean_branch_name = $long_branch_name.Substring($long_branch_name.LastIndexOf('/') + 1)
"##teamcity[setParameter name='Branch Name' value='-$clean_branch_name']"
}
else
{
"##teamcity[setParameter name='Branch Name' value='']"
}
# Deploy Target
if ($long_branch_name.Contains("develop"))
{
"##teamcity[setParameter name='Deploy Environment' value='Development']"
}
else
{
"##teamcity[setParameter name='Deploy Environment' value='']"
}
@nickcurran
Copy link

Cleaning branches like a boss.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment