I want to run some xUnit tests on AppVeyor that needs an available instance of redis. I didn't found Redis within the "Service" of AppVeyor so I end up with a custom solution, as you can see from the appveyor.yml
version: 1.0.{build}
before_build:
- nuget restore .\Hangfire.Redis.StackExchange.sln
- START .\packages\Redis-32.2.6.12.1\tools\redis-server.exe ".\packages\Redis-32.2.6.12.1\tools\redis.conf"
- '@ECHO Redis Started'
build:
publish_nuget: true
publish_nuget_symbols: true
verbosity: minimal
unfortunately the build process stuck at START .\packages\Redis-32.2.6.12.1\tools\redis-server.exe ".\packages\Redis-32.2.6.12.1\tools\redis.conf"
any idea or possible workaround ?
Try running Redis as a Windows service:
before_build:
- nuget restore .\Hangfire.Redis.StackExchange.sln
- packages\Redis-32.2.6.12.1\tools\redis-server.exe --service-install
- packages\Redis-32.2.6.12.1\tools\redis-server.exe --service-start
- '@ECHO Redis Started'
Personally I would always use chocolatey to install any infrastructure needed on on AppVeyor Build Worker. So here's the appveyor.yml that I would use (and which works for me on my own project needing Redis):
version: 1.0.{build}
before_build:
- choco install redis-64
- redis-server --service-install
- redis-server --service-start
- nuget restore .\Hangfire.Redis.StackExchange.sln
build:
publish_nuget: true
publish_nuget_symbols: true
verbosity: minimal
For anyone interested, that's the appveyor.yml that did the trick. It basically download the release directly from github, unzip in a folder, install and start Redis as a service
version: 1.0.{build}
before_build:
- ps: >-
Invoke-WebRequest "https://github.com/MSOpenTech/redis/releases/download/win-2.8.17.4/redis-2.8.17.zip" -OutFile .\redis-2.8.17.zip;
$destFolder = "redis-2.8.17";
$shell = new-object -com shell.application;
$zip = $shell.NameSpace("$pwd\redis-2.8.17.zip");
if (Test-Path $pwd\$destFolder )
{
del $pwd\$destFolder -Force -Recurse
}
md ".\redis-2.8.17";
foreach($item in $zip.items())
{
$shell.Namespace("$pwd\redis-2.8.17").copyhere($item);
it kind of worked
cd $destFolder
.\redis-server.exe --service-install
.\redis-server.exe --service-start
cd ..
- nuget restore Hangfire.Redis.StackExchange.sln
build:
publish_nuget: true
publish_nuget_symbols: true
verbosity: minimal
Here is example of appveyor.yml with a powershell script that works with redis-3.2.100 which is not currently available on chocolately:
appveyor.yml
install:
- cmd: cd c:\ && mkdir c:\redis-3.2.100
- ps: c:\Users\root\repos\<YOUR_REPO>\deploy\redis.ps1
redis.ps1
Add-Type -assembly "system.io.compression.filesystem"
$source="https://github.com/MicrosoftArchive/redis/releases/download/win-3.2.100/Redis-x64-3.2.100.zip"
$destination="c:\redisarchive"
Invoke-WebRequest $source -OutFile $destination
[IO.Compression.ZipFile]::ExtractToDirectory('c:\redisarchive', 'c:\redis-3.2.100')
cd c:\redis-3.2.100
.\redis-server.exe --service-install
.\redis-server.exe --service-start
cd ..
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With