bin/build/vsts-build.ps1

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
<#
Write-Host "Current Path : $((Get-Location).Path)"
 
Write-Host @"
# Listing local variables #
#-------------------------#
 
"@
 
Get-Variable | Format-Table Name, @{
 n = "Type"; e = {
  if ($_.Value -eq $null) { "<Null>" }
  else { $_.Value.GetType().FullName }
 }
}, Value | Out-String | Out-Host
 
Write-Host @"
 
# Listing environment variables #
#-------------------------------#
 
"@
 
Get-ChildItem "env:" | Out-Host
 
Write-Host @"
 
# Listing arguments #
#-------------------#
 
"@
 
$args | Format-List | Out-Host
 
Write-Host "########################################################################################################" -ForegroundColor DarkGreen
#>


$previousVersion = Import-Clixml ".\vsts-version.xml"
$currentVersion = [System.Diagnostics.FileVersionInfo]::GetVersionInfo((Get-Item "bin\dbatools.dll").FullName).FileVersion
Remove-Item ".\vsts-version.xml"

if ($previousVersion -ne $currentVersion)
{
    $branch = $env:BUILD_SOURCEBRANCHNAME
    Write-Host "Previous: $previousVersion | Current: $currentVersion | Library should be updated"
    
    git add .
    git commit -m "VSTS Library Compile ***NO_CI***"
    $errorMessage = git push "https://$env:SYSTEM_ACCESSTOKEN@github.com/sqlcollaborative/dbatools.git" head:$branch 2>&1 
    if ($LASTEXITCODE -gt 0) { throw $errorMessage }
}
else
{
    Write-Host "Version: $currentVersion | Library is up to date"
}