Skip to content

Instantly share code, notes, and snippets.

View IlyaFinkelshteyn's full-sized avatar

Ilya Finkelshteyn IlyaFinkelshteyn

  • Azure App Service
  • Seattle WA
View GitHub Profile
$env:API_TOKEN = "<replace>" # from https://ci.appveyor.com/api-token
$env:APPVEYOR_ACCOUNT_NAME = "<replace>" # from AppVeyor project URL
$env:APPVEYOR_PROJECT_SLUG = "<replace>" # from AppVeyor project URL
$env:CRONTAB_EXPRESSION = "<replace>" # e.g. "5 * * * *"
$headers = @{
"Authorization" = "Bearer $env:API_TOKEN"
"Content-type" = "application/json"
}
# use https://www.linqpad.net/lprun.aspx for C# scripting
install:
- choco install linqpad
- set path=C:\Program Files (x86)\LINQPad5\;%path%
build_script:
- ps: |
$program = @"
// C# script start <<<<<<<<<<<<<<<<<<<<<<<<<
for (int i = 0; i < 3; i++)
$username = "token"
$password = "<VSTS_Token>"
$account = "<VSTS_account_name>"
$project = "<VSTS_project_name>"
$repository = "<VSTS_repository_name>"
$commitId = "<VSTS_commit_id >"
$b = [System.Text.Encoding]::ASCII.GetBytes($username + ":" + $password)
$p = [System.Convert]::ToBase64String($b)
$token = "<replace>"
$headers = @{
"Authorization" = "Bearer $token"
"Content-type" = "application/json"
}
$orgs = Invoke-RestMethod -Uri "https://api.github.com/user/orgs" -Headers $headers -Method GET
$orgs | % {(Invoke-RestMethod -Uri "https://api.github.com/orgs/$($_.login)/teams" -Headers $headers -Method GET).name}
#replace
$token = ""
$env:gh_user = ""
$env:gh_repo = ""
$env:tag_to_find = ""
#replace
$headers = @{
"Authorization" = "Bearer $token"
"Content-type" = "application/json"
#replace
$token = ""
$env:gh_user = ""
$env:gh_repo = ""
$tag_name = ""
$target_commitish = ""
$name = ""
$prerelease = $true/$false
body = ""
#end replace
$env:API_TOKEN="<your_api_key>" # use secure variable in case script runs from the build
$env:APPVEYOR_ACCOUNT_NAME="your_account_name" # no need to setup in case script runs from the build (default environment variable)
$env:APPVEYOR_PROJECT_SLUG="your_project_slug" # no need to setup in case script runs from the build (default environment variable)
$env:RECORDS_NUMBER=10 # build history depth to search
#!!! We assume that if build has artifacts, this file exist in artifacts list
$artifact_file_name = "db.zip"
$headers = @{
"Authorization" = "Bearer $env:API_TOKEN"
if ($env:APPVEYOR_REPO_BRANCH -ne "master") {
$headers = @{
"Authorization" = "Bearer $env:API_TOKEN"
"Content-type" = "application/json"
}
$apiURL = "https://ci.appveyor.com/api/projects/$env:APPVEYOR_ACCOUNT_NAME/$env:APPVEYOR_PROJECT_SLUG"
$s = Invoke-RestMethod -Uri "https://ci.appveyor.com/api/projects/$env:APPVEYOR_ACCOUNT_NAME/$env:APPVEYOR_PROJECT_SLUG/settings" -Headers $headers -Method Get
$s.settings.nextBuildNumber = $s.settings.nextBuildNumber - 1
# install https://github.com/travis-ci/travis.rb#installation
# get API token according https://developer.travis-ci.com/authentication
$env:TRAVIS_API_TOKEN = "<replace>" # must be secure variable set in Environment tab or YAML section
$env:TimeOutMins = <replace> # how long to wait for Travis build to complete (set in Environment tab or YAML section)
$headers = @{
"Authorization" = "token $env:TRAVIS_API_TOKEN"
"Travis-API-Version" = "3"
}
PowerShell sample:
$token = "" # token from https://ci.appveyor.com/api-token
$accountName = "" # account name from project IRL (after project/")
$projectSlug = "" # project slug from project IRL (after account)
$headers = @{
"Authorization" = "Bearer $token"
"Content-type" = "application/json"
}