Deploying to two different locations based on branch commited and built yml parse error

yzolotarev's Avatar

yzolotarev

12 Jul, 2018 11:04 AM

Hello!

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!

  1. 1 Posted by yzolotarev on 12 Jul, 2018 11:49 AM

    yzolotarev's Avatar

    I tried adding for: before the first branches block. It doesn't work either, produces same error.

  2. 2 Posted by yzolotarev on 12 Jul, 2018 02:28 PM

    yzolotarev's Avatar

    Got it solved.

    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"

  3. 3 Posted by yzolotarev on 12 Jul, 2018 02:29 PM

    yzolotarev's Avatar

    It seems u have to watch out for line indents in appveyor.yml it really affects how the code is read.

  4. Support Staff 4 Posted by Owen McDonnell on 12 Jul, 2018 04:13 PM

    Owen McDonnell's Avatar

    Glad you got it sorted.
    Yes, Yaml itself requires functional indentation

Reply to this discussion

Internal reply

Formatting help / Preview (switch to plain text) No formatting (switch to Markdown)

Attaching KB article:

»

Attached Files

You can attach files up to 10MB

If you don't have an account yet, we need to confirm you're human and not a machine trying to post spam.

Keyboard shortcuts

Generic

? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac