Search code examples
continuous-integrationcontinuous-deploymentappveyor

Appveyor builds for all branches instead of specified ones


We have currently three separated appveyor projects, one for each branch in our repository.

Our problem is follwing: Appveyor ignores my filter on github branches. Everytime we make a commit to master, stage or dev it builds on all three projects instead of the single one we did make a commit to.

Each branch has a unique appveyor.yml file looking like this:

This is the appveyor.yml for dev

version: 0.0.{build}
branches:
  only:
  - dev
image: Visual Studio 2017
configuration: dev
before_build:
  - nuget restore
build:
  project: Core.Api.sln
  publish_wap: true
  verbosity: minimal
build_script:
  - ps: .\build.ps1
after_build:
  - cmd: dotnet publish src\Core.Api --output %appveyor_build_folder%\dist
test: off
artifacts:
- path: dist
  name: dist.web
deploy:
...

When we make a commit, it builds on all projects. Any idea??

enter image description here


Solution

  • This happens because each project has Webhook configured on GitHub and each time someone makes a commit, each project build is triggered by webhook. Then, regardless of what branch is configured for project (that is only default branch for manual/API builds), AppVeyor reads appveyor.yml from the branch where commit was done.

    Solution is to use either alternative YAML file names or alternative YAML file location.

    With alternative YAML file names you can have something like appveyor-dev.yml, appveyor-stage.yml files and set specific AppVeyor project to use specific file. With alternative YAML file location is it basically the same, but in other location than repo. I personally like alternative YAML file location more because of less duplication and potential merging issues.

    In both cases when webhook in say branch dev come to stage project, it still will read appveyor-dev.yml and do the right filtering.