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
cd..
del $env:APPVEYOR_BUILD_FOLDER
$gitbashfolder = $env:APPVEYOR_BUILD_FOLDER.Replace("\", "/");
Add-Content -Value "git clone -q --branch=develop git@git.assembla.com:projects^projectA.umbraco.git $gitbashfolder" -Path .\clone.sh
cmd /c "C:\Program Files\Git\git-bash.exe" .\clone.sh
cd $env:APPVEYOR_BUILD_FOLDER
#This script can be used as a deployment script to make environment deployment synchronous.
$token = $env:API_TOKEN #This should be added as a secure variable. Other verisables used in script already exist
$headers = @{
"Authorization" = "Bearer $token"
"Content-type" = "application/json"
}
$body = @{

##For private projects:

Points 1 – 3 needed to allow appveyor to push, as by default SSH key used is deployment key which has read-only permissions.

  • Add the following to appveyor.yml (you can do on_success if you need):
version: 1.0.{build}
environment:
bbpwd:
secure: <encrypted_BitBucket_Password>
clone_script:
- ps: Write-Host "Preparing repo download environment..."
- ps: $bbUserName = $env:APPVEYOR_REPO_NAME.Substring(0, $env:APPVEYOR_REPO_NAME.IndexOf("/"))
- ps: $bytes = [System.Text.Encoding]::ASCII.GetBytes("$bbUserName" + ":" + "$env:bbpwd")
$port = 15672;
[int]$attempt=0
$maxAttempts = 5
while(!$client.Connected -and $attempt -lt $maxAttempts) {
try {
$client = New-Object System.Net.Sockets.TcpClient([System.Net.Sockets.AddressFamily]::InterNetwork)
$attempt++; $client.Connect("127.0.0.1", $port); write-host "service is listening on port $port"
}
catch {
try {
$token = $env:API_TOKEN #should be defined as a secure variable
$headers = @{
"Authorization" = "Bearer $token"
"Content-type" = "application/json"
}
$apiURL = "https://ci.appveyor.com/api/projects/$env:APPVEYOR_ACCOUNT_NAME/$env:APPVEYOR_PROJECT_SLUG"
$history = Invoke-RestMethod -Uri "$apiURL/history?recordsNumber=2" -Headers $headers -Method Get
# Preparation steps:
# On local machine (or you can use https://www.appveyor.com/docs/how-to/rdp-to-build-worker/ instead):
# Install https://pub.storage.googleapis.com/gsutil.zip
# Run gsutil config and complete authentication and configuration
# Check that "$env:USERPROFILE\.boto" created
# Optionally cleanup "$env:USERPROFILE\.boto" (remove comments) and add some additional configuration if needed
# Encode .boto file as a Base64 string (PowerShell sample):
# $bytes = [System.IO.File]::ReadAllBytes("$env:USERPROFILE\.boto")
# [System.Convert]::ToBase64String($bytes)
# Encrypt result with https://ci.appveyor.com/tools/encrypt
Write-Host "Downloading Visual Studio Tools for Azure Functions..."
$exePath = "$($env:USERPROFILE)\WebToolsAzure2015.exe"
(New-Object Net.WebClient).DownloadFile('https://download.microsoft.com/download/F/8/A/F8A2905B-25FF-4C82-95D3-14ED11CF252A/WebToolsAzure2015.exe', $exePath)
Write-Host "Installing Visual Studio Tools for Azure Functions..."
cmd /c start /wait "$exePath" /q
#1 Upload unzipped script or executable
$AzureDeploymentUsername = "<your_deployment_username>"
$AzureDeploymentPassword = "<your_deployment_password>"
$AzureWebsiteName = "<your_website_name>"
$JobName = "<your_webjob_name>"
$inFile = "<your_executable_or_script_relative_path>" # unzipped job file like .cmd, .exe, .js, etc. For example .\test.cmd
$base64AuthInfo = [Convert]::ToBase64String([Text.Encoding]::ASCII.GetBytes(("{0}:{1}" -f $AzureDeploymentUsername,$AzureDeploymentPassword)))
$apiBaseUrl = "https://$AzureWebsiteName.scm.azurewebsites.net/api"
@IlyaFinkelshteyn
IlyaFinkelshteyn / remoteyaml.yml
Last active March 16, 2017 02:13
remoteyaml.yml
version: 1.0.{build}
image: Visual Studio 2017
build: off
test: off
before_build:
- dotnet --info
- dotnet restore Source/PrismLibrary_Core.sln
- dotnet restore Source/PrismLibrary_Xamarin.sln
- nuget restore Source/PrismLibrary_Win10.sln
- nuget restore Source/PrismLibrary_Wpf.sln