Search code examples
continuous-integrationcontinuous-deploymentappveyor

Appveyor deployment into 2 different locations based on branch commit yml parse error


I have a pretty simple scenario where I want to deploy to two different locations depending on the commit happening on dev branch or master. Since its imposible to have two different yml files on these branches since one overwrites the other every time I came about this article here:

https://www.appveyor.com/blog/2014/07/23/appveyor-yml-and-multiple-branches/

The article makes it clear we can use one yml file to set htis up howver I het an error: Error parsing appveyor.yml: (Line: 35, Col: 1, Idx: 554) - (Line: 35, Col: 9, Idx: 562): Duplicate key

Here is my yml

image: Visual Studio 2017

environment: 
  nodejs_version: "6"

platform: 
  - x64

install: 
  - ps: Install-Product node $env:nodejs_version 
  - yarn install --no-progress

build_script: 
  - yarn ng -- build --prod --aot --no-progress

cache: 
  - node_modules -> yarn.lock 
  - "%LOCALAPPDATA%/Yarn"

branches: 
  only: 
  - master

artifacts: 
  path: '\dist\' 
  name: NINJASPA

before_deploy: 
  ssh root@ipadresshere -t "ls; rm -r -v /var/www/asp/ninjacodingfront/*; ls; exit; bash --login"

deploy: 
  provider: Environment 
  name: NinjaCodingFront

branches: 
  only: 
  - dev

artifacts: 
  path: '\dist\' 
  name: NINJASPADEV

before_deploy: 
  ssh root@ipadresshere -t "ls; rm -r -v /var/www/asp/ninjacodingfrontdev/*; ls; exit; bash --login"

deploy: 
  provider: Environment 
  name: NinjaCodingFrontDev

Line 35 is where branches dev comes come:

branches: --------------- (line 35) 
  only: 
  - dev

No idea what to do next, please help. Hope its solvable. Thanks!


Solution

  • So finally this is how its done:

    image: Visual Studio 2017
    
    platform:
      - x64
    
    environment:
       nodejs_version: "6"
    
    install:
      - ps: Install-Product node $env:nodejs_version
      - yarn install --no-progress
    
    build_script:
      - yarn ng -- build --prod --aot --no-progress
    
    cache:
      - node_modules -> yarn.lock
      - "%LOCALAPPDATA%/Yarn"
    
    
    for:
    
    
    -
      branches:
        only:
          - master
    
      deploy:
        provider: Environment
        name: NinjaCodingFront
    
      artifacts:
        path: '\dist\'
        name: NINJASPA
    
      before_deploy:    
        ssh root@xxxxxxxxx -t "ls; rm -r -v /var/www/asp/ninjacodingfront/*; ls; exit; bash --login"
    
    
    
    -
      branches:
        only:
          - dev
    
      deploy:
        provider: Environment
        name: NinjaCodingFrontDev
    
      artifacts:
        path: '\dist\'
        name: NINJASPADEV
    
      before_deploy:    
        ssh root@xxxxxxxxxxx -t "ls; rm -r -v /var/www/asp/ninjacodingfrontdev/*; ls; exit; bash --login"