Conditional cache folder

xhmikosr's Avatar


09 Oct, 2018 09:20 AM


I'm trying to switch to AppVeyor for both Linux and Windows testing for a project f mine. So far everything is good minus one thing: I can't figure out how to conditionally set the npm cache folder so that it works cross-platform

  - '%APPDATA%\npm-cache\ -> .appveyor.yml,package.json,package-lock.json' # need this only on Windows
  - '$HOME/.npm -> .appveyor.yml,package.json,package-lock.json' # need this only on Linux

IMO this should be documented too.

Thanks in advance!

  1. Support Staff 1 Posted by Owen McDonnell on 09 Oct, 2018 03:18 PM

    Owen McDonnell's Avatar

    You can mix windows and linux paths in the same cache list and ones not relevant to the OS should be not found and therefore ignored.

  2. 2 Posted by xhmikosr on 09 Oct, 2018 03:19 PM

    xhmikosr's Avatar

    Well, yeah that's what I'm doing. But there must be some proper way, without having the warning thrown.

  3. Support Staff 3 Posted by Owen McDonnell on 10 Oct, 2018 05:01 PM

    Owen McDonnell's Avatar

    Ok, if you want to avoid the warning then put the cache in a for: construct. Like this,

            - image: Visual Studio 2017
         - '%APPDATA%\npm-cache\ -> .appveyor.yml,package.json,package-lock.json' # need this only on Windows
            - image: Ubuntu
         - '$HOME/.npm -> .appveyor.yml,package.json,package-lock.json' # need this only on Linux
  4. 4 Posted by xhmikosr on 15 Oct, 2018 07:41 AM

    xhmikosr's Avatar

    Thanks, this works.

    Could it be documented though?

  5. Support Staff 5 Posted by Owen McDonnell on 16 Oct, 2018 10:28 PM

    Owen McDonnell's Avatar

    Specializing build matrix job config is documented here though cache: is not explicitly mentioned.

    I think you have a point that it should be.

    Our docs are open source and pull requests are welcome!

  6. Owen McDonnell closed this discussion on 16 Oct, 2018 10:28 PM.

  7. xhmikosr re-opened this discussion on 17 Oct, 2018 07:38 AM

  8. 6 Posted by xhmikosr on 17 Oct, 2018 07:38 AM

    xhmikosr's Avatar

    Haha, I know they are open-source :) Just check the git log in the website repo.

    But anyway, not sure how to phrase this thus the request.

  9. Support Staff 7 Posted by Ilya Finkelshte... on 17 Oct, 2018 04:29 PM

    Ilya Finkelshteyn's Avatar

    I would just add another YAML sample. Because we list settings which are ignored in matrix.for construct, all other are respected.

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


? 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