Separate cache statements per operating system?
This is sort of a cosmetic thing, but I'd like to split the cache statements in my appveyor.yml to only apply depending on Linux or Windows. Is there any way to use the for: or on: statements to filter to an image? I know how to do it by branch, but wanted to do it by image, as some are not applicable.
Also, is there an environment variable format that I can use cross-platform? %USERPROFILE% doesn't resolve on Ubuntu
Example:
cache:
- '%USERPROFILE%\Documents\WindowsPowerShell\Modules -> PSModule.requirements.ps1'
- '%USERPROFILE%\Documents\PowerShell\Modules -> PSModule.requirements.ps1'
- '%LOCALAPPDATA%\PackageManagement\NuGet'
- '/home/appveyor/.dotnet'
- '/home/appveyor/.nuget'
- '/home/appveyor/.cache/powershell'
- '/home/appveyor/.local/share/NuGet'
- '/home/appveyor/.local/share/powershell'
- '/home/appveyor/.config/share/powershell'
Comments are currently closed for this discussion. You can start a new one.
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
Support Staff 1 Posted by Owen McDonnell on 05 Dec, 2018 04:07 PM
Sure, this is described here with the following as an example.
2 Posted by Justin Grote on 05 Dec, 2018 09:03 PM
OK I didn't realize for: was that flexible based on the example. Thanks!
3 Posted by Justin Grote on 05 Dec, 2018 09:33 PM
I tried this and it worked if I only specify one matrix: statement. However, when I try the second matrix statement for the Windows (for windows only tasks) the Appveyor YAML Validator fails saying 'Invalid "matrix" setting: cache (Line: 49, Column: 5)'
Am I doing the syntax right? It validated as valid YAML otherwise (attached). I tried simplifying it down to just cache and same result.
4 Posted by Justin Grote on 05 Dec, 2018 09:49 PM
Nevermind I figured it out, my indents were a little off. Here's the
finished .yml for posterity for future searchers.
# See http://www.appveyor.com/docs/appveyor-yml for many more options
version: '{build}-{branch}'
image:
- Visual Studio 2017
- Ubuntu
#Encrypted Variables - https://ci.appveyor.com/tools/encrypt
environment:
GitHubUserName: JustinGrote
GitHubAPIKey:
secure: MolSn4T0aNBnph/BVkKA8HQ1qvpJjIV3CcjRg3DYynijlOVL5RftqbXD5l0IUw6L
NuGetAPIKey:
secure: HncD30pn+cWRepdP28pyB1l4BNg3x3MdvcNV8EysOhQ5kBFMHVyXiQM0whuUW78P
APPVEYOR_SSH_KEY: ssh-rsa
AAAAB3NzaC1yc2EAAAABJQAAAQEAqOJfFgHyHbQk1d/oCxPn2mGCd92GOFaT9PvA4pICCpMH8w+9Cv1OZpNcwvk+RIzTO9Fm8ilfK/x4gUFrRmAp9BkkmFDhqol0/3e2ZrsxjsYJsUcic/fcRINrDTrwSMaOghUO2fcSTJ3N7WsGKlcG3NXszPgJD95Ulpgk6qvclWJEt15xoYuqHnlhohkXA3zbfcWzuGsMZkuv1fMZB5nEjfLKegzCesQ+swAUaEbUxOeKIFD4VlluDuKONeKqDTETkpLZXKV8pRwDBxgD3i8zQJcSGZ8XoYyPLPbZD/J7AEOap6uYOr4jC8EbFug8SsnxPQ7vxnwslgHoRFzNeYlkIQ==
d8:72:f4:1f:1f:31:4c:01:ce:3e:5a:ec:1b:31:8b:da rsa-jgrote-Jan2016
# Skip on updates to the readme.
# We can force this by adding [skip ci] or [ci skip] anywhere in commit
message
skip_commits:
message: /updated README.*|Update README.*s/
# Skip Tags with GitHub
# Releases are tracked and tagged by the build script in Appveyor, having
this enabled results in a double build
skip_tags: true
#Kick off the CI/CD pipeline. We do test and build in the same script
#To be portable to non-Appveyor builds
build_script:
- ps: .\build.ps1
#Capture the artifacts
artifacts:
- path: Release\*.zip
name: Powershell Module Zip Package
- path: Release\*.nupkg
name: Powershell Module NuGet Package
#Save the following files for faster subsequent builds
for:
- matrix:
only:
- image: Ubuntu
init:
- ps: if ($isLinux -and ($env:APPVEYOR_REPO_COMMIT_MESSAGE -match
'AppveyorSSHDebug')) {"export APPVEYOR_SSH_BLOCK=true" +
[Environment]::NewLine + (iwr -useb '
https://raw.githubusercontent.com/appveyor/ci/master/scripts/enable-ssh.sh').content
| bash -e -}
cache:
- '/home/appveyor/.nuget'
- '/home/appveyor/.cache/powershell'
- '/home/appveyor/.local/share/NuGet'
- '/home/appveyor/.local/share/powershell'
- '/home/appveyor/.config/share/powershell'
on_finish:
- ps: if ($isLinux -and ($env:APPVEYOR_REPO_COMMIT_MESSAGE -match
'AppveyorSSHDebug')) {"export APPVEYOR_SSH_BLOCK=true" +
[Environment]::NewLine + (iwr -useb '
https://raw.githubusercontent.com/appveyor/ci/master/scripts/enable-ssh.sh').content
| bash -e -}
- matrix:
only:
- image: Visual Studio 2017
init:
- ps: if ($isWindows -and ($env:APPVEYOR_REPO_COMMIT_MESSAGE -match
'AppveyorRDPDebug')) {$blockRdp = $true; iex (iwr -useb '
https://raw.githubusercontent.com/appveyor/ci/master/scripts/enable-rdp.ps1').content
}
cache:
- '%USERPROFILE%\Documents\WindowsPowerShell\Modules ->
PSModule.requirements.ps1'
- '%USERPROFILE%\Documents\PowerShell\Modules -> PSModule.requirements.ps1'
- '%LOCALAPPDATA%\PackageManagement\NuGet'
deploy_script:
- ps: .\build.ps1 Publish
on_finish:
- ps: if ($isWindows -and ($env:APPVEYOR_REPO_COMMIT_MESSAGE -match
'AppveyorRDPDebug')) {$blockRdp = $true; iex (iwr -useb '
https://raw.githubusercontent.com/appveyor/ci/master/scripts/enable-rdp.ps1').content
}
5 Posted by Justin Grote on 05 Dec, 2018 09:50 PM
Err, that formatting didn't come out as expected. Attached.
Support Staff 6 Posted by Owen McDonnell on 05 Dec, 2018 11:33 PM
Cool, thanks for your contribution to posterity!
Owen McDonnell closed this discussion on 05 Dec, 2018 11:33 PM.