Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Generated a build number in the format year.month.day.buildCounter-story
- # where story is derived from the branch name
- #
- # Parameters are expected in the following order:
- # 1. build counter
- # 2. branch name in the format develop | XXXX-ddd
- param (
- [parameter(Mandatory=$true)] [int]$buildCounter,
- [parameter(Mandatory=$true)] [string]$branch
- )
- try
- {
- if ($branch -eq "develop")
- {
- $branch = ""
- }
- else
- {
- # strip path root
- $branch = [regex]::Replace($branch, "^(?:.+\/)", "")
- $match = [regex]::Match($branch, "^([a-zA-Z]{3,4})(?:[-_ ])?(\d+)")
- if ($match.Success)
- {
- $branch = $('-{0}{1}'-f $match.Groups[1].Value, $match.Groups[2].Value)
- }
- }
- $buildNumber = $([DateTime]::UtcNow.ToString('yyyy.M.d') + '.' + $buildCounter + $branch)
- Write-Host $("##teamcity[message text='buildNumber: {0}']" -f $buildNumber)
- Write-Host $("##teamcity[buildNumber '{0}']" -f $buildNumber)
- } Catch {
- Write-Host $("##teamcity[message text='{0}' status='ERROR']" -f $_.Exception.Message.Replace("]", "|]"))
- [System.Environment]::Exit(1)
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement