Advertisement
Guest User

Untitled

a guest
Jun 25th, 2019
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.12 KB | None | 0 0
  1. # Generated a build number in the format year.month.day.buildCounter-story
  2. # where story is derived from the branch name
  3. #
  4. # Parameters are expected in the following order:
  5. # 1. build counter
  6. # 2. branch name in the format develop | XXXX-ddd
  7.  
  8. param (
  9. [parameter(Mandatory=$true)] [int]$buildCounter,
  10. [parameter(Mandatory=$true)] [string]$branch
  11. )
  12.  
  13. try
  14. {
  15. if ($branch -eq "develop")
  16. {
  17. $branch = ""
  18. }
  19. else
  20. {
  21. # strip path root
  22. $branch = [regex]::Replace($branch, "^(?:.+\/)", "")
  23.  
  24. $match = [regex]::Match($branch, "^([a-zA-Z]{3,4})(?:[-_ ])?(\d+)")
  25. if ($match.Success)
  26. {
  27. $branch = $('-{0}{1}'-f $match.Groups[1].Value, $match.Groups[2].Value)
  28. }
  29. }
  30.  
  31. $buildNumber = $([DateTime]::UtcNow.ToString('yyyy.M.d') + '.' + $buildCounter + $branch)
  32.  
  33. Write-Host $("##teamcity[message text='buildNumber: {0}']" -f $buildNumber)
  34. Write-Host $("##teamcity[buildNumber '{0}']" -f $buildNumber)
  35. } Catch {
  36. Write-Host $("##teamcity[message text='{0}' status='ERROR']" -f $_.Exception.Message.Replace("]", "|]"))
  37. [System.Environment]::Exit(1)
  38. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement