You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

appveyor.ps1 2.5KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. function FetchAndUnzip
  2. {
  3. param ([string]$Url, [string]$Out)
  4. $tmp = [System.IO.Path]::GetTempFileName()
  5. [System.Reflection.Assembly]::LoadWithPartialName('System.Net.Http') | Out-Null
  6. $client = (New-Object System.Net.Http.HttpClient)
  7. try
  8. {
  9. if (-not([string]::IsNullOrEmpty($env:GITHUB_TOKEN)))
  10. {
  11. $credentials = [string]::Format([System.Globalization.CultureInfo]::InvariantCulture, "{0}:", $env:GITHUB_TOKEN);
  12. $credentials = [Convert]::ToBase64String([System.Text.Encoding]::ASCII.GetBytes($credentials));
  13. $client.DefaultRequestHeaders.Authorization = (New-Object System.Net.Http.Headers.AuthenticationHeaderValue("Basic", $credentials));
  14. }
  15. $contents = $client.GetByteArrayAsync($url).Result;
  16. [System.IO.File]::WriteAllBytes($tmp, $contents);
  17. }
  18. finally
  19. {
  20. $client.Dispose()
  21. }
  22. if (-not(Test-Path $Out))
  23. {
  24. mkdir $Out | Out-Null
  25. }
  26. [System.Reflection.Assembly]::LoadWithPartialName('System.IO.Compression.FileSystem') | Out-Null
  27. [System.IO.Compression.ZipFile]::ExtractToDirectory($tmp, $Out)
  28. }
  29. function InstallAppveyorTools
  30. {
  31. $travisUtilsVersion = "57"
  32. $localPath = "$env:USERPROFILE\.local"
  33. $travisUtilsPath = "$localPath\travis-utils-$travisUtilsVersion"
  34. if (Test-Path $travisUtilsPath)
  35. {
  36. echo "Reusing the Travis Utils version $travisUtilsVersion already downloaded under $travisUtilsPath"
  37. }
  38. else
  39. {
  40. $url = "https://github.com/SonarSource/travis-utils/archive/v$travisUtilsVersion.zip"
  41. echo "Downloading Travis Utils version $travisUtilsVersion from $url into $localPath"
  42. FetchAndUnzip $url $localPath
  43. }
  44. $mavenLocalSettings = "$env:USERPROFILE\.m2\settings.xml"
  45. echo "Installating settings.xml into $mavenLocalSettings"
  46. Copy-Item "$travisUtilsPath\m2\settings-public.xml" $mavenLocalSettings -Force -Recurse
  47. $env:ORCHESTRATOR_CONFIG_URL = ""
  48. $env:TRAVIS = "ORCH-332"
  49. }
  50. function CheckLastExitCode
  51. {
  52. param ([int[]]$SuccessCodes = @(0))
  53. if ($SuccessCodes -notcontains $LastExitCode)
  54. {
  55. $msg = @"
  56. EXE RETURNED EXIT CODE $LastExitCode
  57. CALLSTACK:$(Get-PSCallStack | Out-String)
  58. "@
  59. throw $msg
  60. }
  61. }
  62. InstallAppveyorTools
  63. mvn verify "--batch-mode" "-B" "-e" "-V"
  64. CheckLastExitCode