There are two options to have branch-specific configuration with
appveyor.ymlinto each branch with branch-specific settings.
- Use Conditional build configuration where
appveyor.ymlhas a list of configurations for different branches.
The problem with 1st approach is merging as you are overriding
appveyor.yml in the base branch with one from the branch being merged.
2nd approach requires
appveyor.yml of the following format:
# configuration for "master" branch # build in Release mode and deploy to Azure - branches: only: - master configuration: Release deploy: provider: AzureCS ... # configuration for all branches starting from "dev-" # build in Debug mode and deploy locally for testing - branches: only: - /dev-.*/ configuration: Debug deploy: provider: Local ... # "fall back" configuration for all other branches # no "branches" section defined # do not deploy at all - configuration: Debug
While this approach works great in the most cases there is one incovenience though - with large configuration and many branches
appveyor.yml becomes really unmanageable and error-prone as you have to repeat (copy-paste) entire configuration for every branch.
We just deployed an update to AppVeyor that allows sharing common configuration between branches in a single
There is new
for node with a list of branch-specific configurations overriding common configuration defined on the top most level, for example:
# common configuration for ALL branches environment: MY_VAR1: value-A init: - do_something_on_init.cmd install: - do_something_on_install.cmd configuration: Debug # here we are going to override common configuration for: # override settings for `master` branch - branches: only: - master configuration: Release deploy: provider: FTP ... # override settings for `dev-*` branches - branches: only: - /dev-.*/ environment: MY_VAR2: value-B deploy: provider: Local ...
In the example above we define
install sections for all branches as well as stating that default
Debug. Then, for
master branch we override default settings by changing
Release and adding deployment with
FTP provider. For
dev-* branches we define a second environment variable
MY_VAR2 and enable deployment to
Configuration merging rules:
- Scalar values such as
platform, etc. defined on branch level override default ones;
- Script sections such
test_script, etc. defined on branch level override default ones;
- Environment variables defined in
environmentsections are merged (new) and overridden (existing);
- Build matrix defined on branch level merges with default one;
notificationssection can be either overridden or extended.
For example, consider the following configuration:
artifacts: - path: bin deploy: - provider: Local ... notifications: - provider: Email ... for: branches: only: - master artifacts: - path: docs deploy: off notifications: provider: Slack ...
In the example above we do the following:
masterbranch we adding
docsfolder to artifacts definition, so both
docsfolders collected. Both default and branch-specific collections were merged.
masterbranch we disable any deployment.
noneon branch-level clears default collection.
masterbranch we replace all notifications on default level with a single
Follow us on Twitter: @appveyor