Created
August 3, 2017 17:35
-
-
Save IlyaFinkelshteyn/d9029406873f9502b1a14e234275f547 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$gh_user = "<github_user>" | |
$gh_repo = "<github_repo>" | |
$sha = "<your_sha>" | |
$av_account = $gh_user # not always true | |
$av_project_slug = $gh_repo # not always true | |
$av_api_token = "<your_appveyor_api_token>" | |
# not officially supported way to get branch | |
# add authorization header for private repo | |
$resp = Invoke-WebRequest -Uri "https://github.com/$gh_user/$gh_repo/commit/$sha" | |
$html = New-Object -ComObject "htmlfile" | |
$html.IHTMLDocument2_write($resp.Content) | |
$branch = ($html.all.tags("li") | Where-Object {$_.className -eq "branch"}).innerText | |
Write-host "branch: $branch" | |
$headers = @{ | |
"Authorization" = "Bearer $av_api_token" | |
"Content-type" = "application/json" | |
} | |
$body = @{ | |
accountName=$av_account | |
projectSlug=$av_project_slug | |
branch=$branch | |
commitId=$sha | |
} | |
$body = $body | ConvertTo-Json | |
Invoke-RestMethod -Uri 'https://ci.appveyor.com/api/builds' -Headers $headers -Body $body -Method POST |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment