Running builds on Google Compute Engine

Enable custom build environment

Currently custom build environment feature is not generally available. It is being enabled for specific accounts per request. Please send an email to team@appveyor.com if you decide to try this feature.

Select or create Google Cloud Platform project

  • Open Google Cloud Platform menu and select existing or create new project to use for AppVeyor build environment

Set up credentials

Create account and download certificate

  • Open Google Cloud Platform menu navigate to IAM & Admin
  • Select Service accounts and press Create service account
    • Set descriptive Service account name, for example Appveyor CI
      • Service account ID will be automatically regenerated, write it down to use later in AppVeyor settings
    • Select Project > Editor in Role menu
    • Check Furnish a new private key
      • Select P12
    • Press CREATE
    • Close Service account created window
      • Leave default password unchanged
    • Certificate in P12 format should be saved to local computer
      • Remember it’s location and optionally re-save certificate in some secure place

Convert certificate to Base64 string

  • Run the following PowerShell commands:
$bytes = [System.IO.File]::ReadAllBytes("<path-to-P12-file>")
$base64Str = [System.Convert]::ToBase64String($bytes)
[System.IO.File]::WriteAllText("<path-to-result-TXT-file>", $base64Str)
  • Remember location of the result TXT file

Create Master VM

  • Go back to Google Cloud Platform menu and select Compute engine
  • Navigate to VM instances and press Create
    • Set descriptive Name, for example master-vm
    • Optionally change Zone, to be the same as build VMs, closer to other GCE or non-GCE resources needed during build, test or deployment
    • Optionally increase number of CPUs or memory
    • Press Change in Boot disk
      • Select Windows Server 2012 R2
      • Select SSD persistent disk
    • Press Select and then Create
    • In drop-down menu near RDP select Create or reset Windows password
      • Set user name to appveyor and press Set
      • Save auto-generated password for future use
    • In drop-down menu near RDP select Download RDP file
      • Click RDP file and in RDP window change username to appveyor and use password saved before

Setup Master VM

Prepare Master VM snapshot

  • Optionally restart Master VM to ensure AppVeyor build agent is started on automatically interactively
  • Shutdown Master VM
  • In Compute engine menu select Snapshots and press Create snapshot
    • Set descriptive Name, for example build-vm-2017-05-09. It is handy to include date to manage build images versions
    • Select Master VM created before as a Source disk
    • Press CREATE

Setting up custom cloud and images in AppVeyor

  • Login to AppVeyor portal
  • Navigate to your account name on the top right and select Build environment option from drop-down menu
    • If Build environment option is not available, please contact team@appveyor.com and ask to enable Private build clouds feature
  • Press Add cloud, select cloud type Google Compute Engine

Complete the following settings:

  • Name: Name for your private build cloud. Make it meaningful and short to be able to use in YAML configuration
  • Google account
  • Virtual machine configuration
    • Zone name: select the same as used for Master VM
    • Machine type (size): select depending on performance you need
    • Tags: Optionally add tags
  • Networking
    • Network name: Optionally set custom VPC network
      • Select Assign external IP address if VMs need to be accessible from outside
  • Images
    • IMAGE NAME: Image name as you want to see it in AppVeyor UI and YAML, for example VS2017 on GCE
    • SNAPSHOT OR IMAGE NAME: Image name as it was set in Prepare Master VM snapshot step
    • SIZE, GB: VM disk size in Gb
  • Open Failure strategy and set the following:
    • Job start timeout, seconds: 360 is good enough for GCE. However, if VM creation and build start takes longer for you, please adjust accordingly
    • Provisioning attempts: 2 is good for start. Later you may need to change it according to your observations

Make build worker image available for configuration

  • Navigate to Build environment > Build worker images
  • Press Add image
  • Enter what you set as IMAGE NAME in previous step

How to route build to your own cloud

At project level:

  • UI:
    • Settings > Environment > Build cloud: Select your private build cloud name from drop-down
    • Settings > Environment > Build worker image: Select your build worker image from drop-down
  • YAML:
build_cloud: <private_build_cloud_name>
image: <private_build_cloud_image>

At project level:

  • Set environment variable “APPVEYOR_BUILD_WORKER_CLOUD” to your private build cloud name
    • This assumes that default and custom build clouds have build worker image with the same name (for example Visual Studio 2015)
Did you know that you can edit this page on GitHub and send us a Pull Request?