aboutsummaryrefslogtreecommitdiffstats
path: root/appveyor.ps1
blob: b3ecc5561cc685c04379d38461512ab300d5e3c2 (plain)
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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
function FetchAndUnzip
{
        param ([string]$Url, [string]$Out)

        $tmp = [System.IO.Path]::GetTempFileName()
        [System.Reflection.Assembly]::LoadWithPartialName('System.Net.Http') | Out-Null
        $client = (New-Object System.Net.Http.HttpClient)
        try
        {
                if (-not([string]::IsNullOrEmpty($env:GITHUB_TOKEN)))
                {
                        $credentials = [string]::Format([System.Globalization.CultureInfo]::InvariantCulture, "{0}:", $env:GITHUB_TOKEN);
                        $credentials = [Convert]::ToBase64String([System.Text.Encoding]::ASCII.GetBytes($credentials));
                        $client.DefaultRequestHeaders.Authorization = (New-Object System.Net.Http.Headers.AuthenticationHeaderValue("Basic", $credentials));
                }
                $contents = $client.GetByteArrayAsync($url).Result;
                [System.IO.File]::WriteAllBytes($tmp, $contents);
        }
        finally
        {
                $client.Dispose()
        }

        if (-not(Test-Path $Out))
        {
                mkdir $Out | Out-Null
        }
        [System.Reflection.Assembly]::LoadWithPartialName('System.IO.Compression.FileSystem') | Out-Null
        [System.IO.Compression.ZipFile]::ExtractToDirectory($tmp, $Out)
}

function InstallAppveyorTools
{
        $travisUtilsVersion = "33"
        $localPath = "$env:USERPROFILE\.local"
        $travisUtilsPath = "$localPath\travis-utils-$travisUtilsVersion"
        if (Test-Path $travisUtilsPath)
        {
                echo "Reusing the Travis Utils version $travisUtilsVersion already downloaded under $travisUtilsPath"
        }
        else
        {
                $url = "https://github.com/SonarSource/travis-utils/archive/v$travisUtilsVersion.zip"
                echo "Downloading Travis Utils version $travisUtilsVersion from $url into $localPath"
                FetchAndUnzip $url $localPath
        }

        $mavenLocalSettings = "$env:USERPROFILE\.m2\settings.xml"
        echo "Installating settings.xml into $mavenLocalSettings"
        Copy-Item "$travisUtilsPath\m2\settings-public.xml" $mavenLocalSettings -Force -Recurse

        $env:ORCHESTRATOR_CONFIG_URL = ""
        $env:TRAVIS = "ORCH-332"
}


function CheckLastExitCode
{
    param ([int[]]$SuccessCodes = @(0))

    if ($SuccessCodes -notcontains $LastExitCode)
	{
        $msg = @"
EXE RETURNED EXIT CODE $LastExitCode
CALLSTACK:$(Get-PSCallStack | Out-String)
"@
        throw $msg
    }
}

InstallAppveyorTools
mvn verify "--batch-mode" "-B" "-e" "-V"
CheckLastExitCode