1
1
Param (
2
- [string ]$ref = " master" ,
2
+ [string ]$ref = " master" ,
3
3
[switch ]$verbose = $False
4
4
)
5
5
@@ -8,95 +8,95 @@ $ErrorActionPreference = "Stop"
8
8
9
9
function Invoke-RestMethod-Ex ($url , $downloadLocation ) {
10
10
11
- $irmParams = @ {
12
- }
11
+ $irmParams = @ {
12
+ }
13
13
14
- Write-Host - ForegroundColor " White" " -> Get $url "
14
+ Write-Host - ForegroundColor " White" " -> Get $url "
15
15
16
- $proxy = [System.Net.WebRequest ]::GetSystemWebProxy()
17
- if ($proxy ) {
18
- $proxy.Credentials = [System.Net.CredentialCache ]::DefaultCredentials
19
- $proxyUri = $proxy.GetProxy (" $url " )
16
+ $proxy = [System.Net.WebRequest ]::GetSystemWebProxy()
17
+ if ($proxy ) {
18
+ $proxy.Credentials = [System.Net.CredentialCache ]::DefaultCredentials
19
+ $proxyUri = $proxy.GetProxy (" $url " )
20
20
21
- if (" $proxyUri " -ne " $url " ) {
22
- $irmParams.Proxy = " $proxyUri "
23
- $irmParams.ProxyUseDefaultCredentials = $true
21
+ if (" $proxyUri " -ne " $url " ) {
22
+ $irmParams.Proxy = " $proxyUri "
23
+ $irmParams.ProxyUseDefaultCredentials = $true
24
+ }
24
25
}
25
- }
26
26
27
- if ($downloadLocation ) {
28
- $irmParams.OutFile = " $downloadLocation "
29
- }
27
+ if ($downloadLocation ) {
28
+ $irmParams.OutFile = " $downloadLocation "
29
+ }
30
30
31
- $output = Invoke-RestMethod @irmParams - ContentType " application/json" - Method " Get" - Uri " $url "
31
+ $output = Invoke-RestMethod @irmParams - ContentType " application/json" - Method " Get" - Uri " $url "
32
32
33
- if ($verbose ) {
34
- Write-Host - ForegroundColor " Gray" " output = $ ( ConvertTo-Json $output ) "
35
- }
33
+ if ($verbose ) {
34
+ Write-Host - ForegroundColor " Gray" " output = $ ( ConvertTo-Json $output ) "
35
+ }
36
36
37
- return $output
37
+ return $output
38
38
}
39
39
40
40
function Extract-BuildIdentifier ($statuses , $forContext ) {
41
41
42
- $status = $statuses | where { $_.context -eq $forContext } | select - First 1
42
+ $status = $statuses | where { $_.context -eq $forContext } | select - First 1
43
43
44
- if (($status -eq $null ) -or (" success" .CompareTo($status.state ) -ne 0 )) {
45
- throw " No successful status has been found for context `" $forContext `" ."
46
- }
44
+ if (($status -eq $null ) -or (" success" .CompareTo($status.state ) -ne 0 )) {
45
+ throw " No successful status has been found for context `" $forContext `" ."
46
+ }
47
47
48
- $buildNumber = $status.target_url.Split (" /" )[-1 ]
48
+ $buildNumber = $status.target_url.Split (" /" )[-1 ]
49
49
50
- return $buildNumber
50
+ return $buildNumber
51
51
}
52
52
53
53
function Download-AppVeyor-Artifacts ($statuses , $downloadLocation ) {
54
- $prOrBranch = " branch"
54
+ $prOrBranch = " branch"
55
55
56
- if ($ref.StartsWith (" pull/" )) {
57
- $prOrBranch = " pr"
58
- }
56
+ if ($ref.StartsWith (" pull/" )) {
57
+ $prOrBranch = " pr"
58
+ }
59
59
60
- $buildIdentifier = Extract- BuildIdentifier $statuses " continuous-integration/appveyor/$prOrBranch "
60
+ $buildIdentifier = Extract- BuildIdentifier $statuses " continuous-integration/appveyor/$prOrBranch "
61
61
62
- Write-Host - ForegroundColor " Yellow" " Retrieving AppVeyor build `" $buildIdentifier `" "
63
- $build = Invoke-RestMethod - Ex " https://ci.appveyor.com/api/projects/libgit2/libgit2sharp-nativebinaries/build/$buildIdentifier "
62
+ Write-Host - ForegroundColor " Yellow" " Retrieving AppVeyor build `" $buildIdentifier `" "
63
+ $build = Invoke-RestMethod - Ex " https://ci.appveyor.com/api/projects/libgit2/libgit2sharp-nativebinaries/build/$buildIdentifier "
64
64
65
- $jobId = $build.build.jobs [0 ].jobId
65
+ $jobId = $build.build.jobs [0 ].jobId
66
66
67
- Write-Host - ForegroundColor " Yellow" " Retrieving AppVeyor job `" $jobId `" artifacts"
68
- $artifacts = Invoke-RestMethod - Ex " https://ci.appveyor.com/api/buildjobs/$jobId /artifacts"
67
+ Write-Host - ForegroundColor " Yellow" " Retrieving AppVeyor job `" $jobId `" artifacts"
68
+ $artifacts = Invoke-RestMethod - Ex " https://ci.appveyor.com/api/buildjobs/$jobId /artifacts"
69
69
70
- ForEach ($artifact in $artifacts ) {
71
- $artifactFileName = $artifacts [0 ].fileName
72
- $localArtifactPath = " $downloadLocation \$artifactFileName "
70
+ ForEach ($artifact in $artifacts ) {
71
+ $artifactFileName = $artifacts [0 ].fileName
72
+ $localArtifactPath = " $downloadLocation \$artifactFileName "
73
73
74
- Write-Host - ForegroundColor " Yellow" " Downloading `" $artifactFileName `" "
75
- Invoke-RestMethod - Ex " https://ci.appveyor.com/api/buildjobs/$jobId /artifacts/$artifactFileName " $localArtifactPath
76
- }
74
+ Write-Host - ForegroundColor " Yellow" " Downloading `" $artifactFileName `" "
75
+ Invoke-RestMethod - Ex " https://ci.appveyor.com/api/buildjobs/$jobId /artifacts/$artifactFileName " $localArtifactPath
76
+ }
77
77
}
78
78
79
79
function Download-Travis-Artifacts ($statuses , $downloadLocation ) {
80
- $prOrBranch = " push"
80
+ $prOrBranch = " push"
81
81
82
- if ($ref.StartsWith (" pull/" )) {
83
- $prOrBranch = " pr"
84
- }
82
+ if ($ref.StartsWith (" pull/" )) {
83
+ $prOrBranch = " pr"
84
+ }
85
85
86
- $buildIdentifier = Extract- BuildIdentifier $statuses " continuous-integration/travis-ci/$prOrBranch "
86
+ $buildIdentifier = Extract- BuildIdentifier $statuses " continuous-integration/travis-ci/$prOrBranch "
87
87
88
- Write-Host - ForegroundColor " Yellow" " Retrieving Travis build `" $buildIdentifier `" "
89
- $build = Invoke-RestMethod - Ex " https://api.travis-ci.org/builds/$buildIdentifier "
88
+ Write-Host - ForegroundColor " Yellow" " Retrieving Travis build `" $buildIdentifier `" "
89
+ $build = Invoke-RestMethod - Ex " https://api.travis-ci.org/builds/$buildIdentifier "
90
90
91
- $buildNumber = $build.number
91
+ $buildNumber = $build.number
92
92
93
- ForEach ($platform in @ (" linux" , " osx" )) {
94
- $artifactFileName = " binaries-$platform -$buildNumber .zip"
95
- $localArtifactPath = " $downloadLocation \$artifactFileName "
93
+ ForEach ($platform in @ (" linux" , " osx" )) {
94
+ $artifactFileName = " binaries-$platform -$buildNumber .zip"
95
+ $localArtifactPath = " $downloadLocation \$artifactFileName "
96
96
97
- Write-Host - ForegroundColor " Yellow" " Downloading `" $artifactFileName `" "
98
- Invoke-RestMethod - Ex " https://dl.bintray.com/libgit2/compiled-binaries/$artifactFileName " $localArtifactPath
99
- }
97
+ Write-Host - ForegroundColor " Yellow" " Downloading `" $artifactFileName `" "
98
+ Invoke-RestMethod - Ex " https://dl.bintray.com/libgit2/compiled-binaries/$artifactFileName " $localArtifactPath
99
+ }
100
100
}
101
101
102
102
# #####################################################
@@ -108,13 +108,14 @@ Write-Host -ForegroundColor "Yellow" "Creating temporary folder at `"$path`""
108
108
New-Item " $path " - type Directory > $null
109
109
110
110
if ($ref.StartsWith (" pull/" )) {
111
- $pr = $ref.Replace (" pull/" , " " )
112
- Write-Host - ForegroundColor " Yellow" " Retrieving pull request information for pull request $pr "
111
+ $pr = $ref.Replace (" pull/" , " " )
112
+ Write-Host - ForegroundColor " Yellow" " Retrieving pull request information for pull request $pr "
113
113
114
- $prData = Invoke-RestMethod - Ex " https://api.github.com/repos/libgit2/libgit2sharp.nativebinaries/pulls/$pr "
115
- $statusesUrl = $prData.statuses_url
116
- } else {
117
- $statusesUrl = " https://api.github.com/repos/libgit2/libgit2sharp.nativebinaries/commits/$ref /statuses"
114
+ $prData = Invoke-RestMethod - Ex " https://api.github.com/repos/libgit2/libgit2sharp.nativebinaries/pulls/$pr "
115
+ $statusesUrl = $prData.statuses_url
116
+ }
117
+ else {
118
+ $statusesUrl = " https://api.github.com/repos/libgit2/libgit2sharp.nativebinaries/commits/$ref /statuses"
118
119
}
119
120
120
121
Write-Host - ForegroundColor " Yellow" " Retrieving LibGit2Sharp.NativeBinaries latest CI statuses of `" $ref `" "
0 commit comments