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