Skip to content

Instantly share code, notes, and snippets.

@IlyaFinkelshteyn
Created August 3, 2017 17:35
Show Gist options
  • Save IlyaFinkelshteyn/d9029406873f9502b1a14e234275f547 to your computer and use it in GitHub Desktop.
Save IlyaFinkelshteyn/d9029406873f9502b1a14e234275f547 to your computer and use it in GitHub Desktop.
$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