Skip to content

Commit 54627f7

Browse files
author
Edward Thomson
committed
build artifacts: allow to create from any branch
Take the branch name or a pull request number.
1 parent edf2347 commit 54627f7

File tree

1 file changed

+24
-4
lines changed

1 file changed

+24
-4
lines changed

download.build.artifacts.and.package.ps1

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
Param(
2+
[string]$ref = "master",
23
[switch]$verbose = $False
34
)
45

@@ -50,8 +51,13 @@ function Extract-BuildIdentifier($statuses, $forContext) {
5051
}
5152

5253
function Download-AppVeyor-Artifacts($statuses, $downloadLocation) {
54+
$prOrBranch = "branch"
5355

54-
$buildIdentifier = Extract-BuildIdentifier $statuses "continuous-integration/appveyor/branch"
56+
if ($ref.StartsWith("pull/")) {
57+
$prOrBranch = "pr"
58+
}
59+
60+
$buildIdentifier = Extract-BuildIdentifier $statuses "continuous-integration/appveyor/$prOrBranch"
5561

5662
Write-Host -ForegroundColor "Yellow" "Retrieving AppVeyor build `"$buildIdentifier`""
5763
$build = Invoke-RestMethod-Ex "https://ci.appveyor.com/api/projects/libgit2/libgit2sharp-nativebinaries/build/$buildIdentifier"
@@ -71,8 +77,13 @@ function Download-AppVeyor-Artifacts($statuses, $downloadLocation) {
7177
}
7278

7379
function Download-Travis-Artifacts($statuses, $downloadLocation) {
80+
$prOrBranch = "push"
81+
82+
if ($ref.StartsWith("pull/")) {
83+
$prOrBranch = "pr"
84+
}
7485

75-
$buildIdentifier = Extract-BuildIdentifier $statuses "continuous-integration/travis-ci/push"
86+
$buildIdentifier = Extract-BuildIdentifier $statuses "continuous-integration/travis-ci/$prOrBranch"
7687

7788
Write-Host -ForegroundColor "Yellow" "Retrieving Travis build `"$buildIdentifier`""
7889
$build = Invoke-RestMethod-Ex "https://api.travis-ci.org/builds/$buildIdentifier"
@@ -96,9 +107,18 @@ $path = [System.IO.Path]::Combine($env:Temp, [System.IO.Path]::GetRandomFileName
96107
Write-Host -ForegroundColor "Yellow" "Creating temporary folder at `"$path`""
97108
New-Item "$path" -type Directory > $null
98109

99-
$ref = "master"
110+
if ($ref.StartsWith("pull/")) {
111+
$pr = $ref.Replace("pull/", "")
112+
Write-Host -ForegroundColor "Yellow" "Retrieving pull request information for pull request $pr"
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"
118+
}
119+
100120
Write-Host -ForegroundColor "Yellow" "Retrieving LibGit2Sharp.NativeBinaries latest CI statuses of `"$ref`""
101-
$statuses = Invoke-RestMethod-Ex "https://api.github.com/repos/libgit2/libgit2sharp.nativebinaries/commits/$ref/statuses"
121+
$statuses = Invoke-RestMethod-Ex $statusesUrl
102122

103123
Download-AppVeyor-Artifacts $statuses $path
104124
Download-Travis-Artifacts $statuses $path

0 commit comments

Comments
 (0)