Search code examples
elasticsearchchocolateyappveyor

How do I reliably install and run Elasticsearch on an AppVeyor build agent?


I have a .NET project with integration tests that require a local running instance of Elasticsearch. I'm trying to get these running on AppVeyor. Here are the relevant bits from my appveyor.yml:

install:
  - cinst elasticsearch
  - elasticsearch-service-x64 start

The first command, which installs Elasticsearch via Chocolatey, works swimmingly. The second, which starts the service, succeeds roughly half the time and all my tests against the Elasticsearch instance are passing. The other half, however, the build fails immediately after that line with this message:

Command exited with code 5

Any ideas on how I can get this working reliably?

For completeness, here's the output of a failed build:

cinst elasticsearch
Chocolatey v0.10.8
Installing the following packages:
elasticsearch
By installing you accept licenses for the packages.
Progress: Downloading server-jre8 8.0.172... 100%
Progress: Downloading elasticsearch 6.2.4... 100%
server-jre8 v8.0.172 [Approved]
server-jre8 package files install completed. Performing other installation steps.
Hashes match.
Extracting C:\Users\appveyor\AppData\Local\Temp\chocolatey\server-jre8\8.0.172\server-jre-8u172-windows-x64.tar.gz to C:\Users\appveyor\AppData\Local\Temp\chocolatey\server-jre8\8.0.172...
C:\Users\appveyor\AppData\Local\Temp\chocolatey\server-jre8\8.0.172
Extracting C:\Users\appveyor\AppData\Local\Temp\chocolatey\server-jre8\8.0.172\server-jre-8u172-windows-x64.tar to C:\tools\Java\server-jre...
C:\tools\Java\server-jre
PATH environment variable does not have %JAVA_HOME%\bin in it. Adding...
C:\Program Files (x86)\Microsoft SDKs\Azure\CLI2\wbin;C:\Perl\site\bin;C:\Perl\bin;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files\7-Zip;C:\Tools\GitVersion;C:\Tools\NuGet;C:\Program Files\Microsoft\Web Platform Installer\;C:\Tools\PsTools;C:\Program Files\Git LFS;C:\Program Files\Mercurial\;C:\Program Files (x86)\Subversion\bin;C:\Tools\WebDriver;C:\Tools\Coverity\bin;C:\Tools\MSpec;C:\Tools\NUnit\bin;C:\Tools\NUnit3;C:\Tools\xUnit;C:\Program Files\nodejs;C:\Program Files (x86)\iojs;C:\Program Files\iojs;C:\Users\appveyor\AppData\Roaming\npm;C:\Program Files\Microsoft SQL Server\120\Tools\Binn\;C:\Program Files\Microsoft SQL Server\Client SDK\ODBC\110\Tools\Binn\;C:\Program Files (x86)\Microsoft SQL Server\120\Tools\Binn\;C:\Program Files\Microsoft SQL Server\120\DTS\Binn\;C:\Program Files (x86)\Microsoft SQL Server\120\Tools\Binn\ManagementStudio\;C:\Program Files (x86)\Microsoft SQL Server\120\DTS\Binn\;C:\Program Files (x86)\Microsoft SQL Server\130\Tools\Binn\;C:\Program Files\Microsoft SQL Server\130\Tools\Binn\;C:\Program Files (x86)\Microsoft SQL Server\130\DTS\Binn\;C:\Program Files\Microsoft SQL Server\130\DTS\Binn\;C:\Program Files\Microsoft SQL Server\Client SDK\ODBC\130\Tools\Binn\;C:\Ruby193\bin;C:\go\bin;C:\Program Files\Java\jdk1.8.0\bin;C:\Program Files (x86)\Apache\Maven\bin;C:\Python27;C:\Python27\Scripts;C:\Program Files (x86)\CMake\bin;C:\Tools\curl\bin;C:\Users\appveyor\.dnx\bin;C:\Program Files\Microsoft DNX\Dnvm\;C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\MSBuild\15.0\Bin;C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\Common7\IDE\Extensions\Microsoft\SQLDB\DAC\130;C:\Program Files\Amazon\AWSCLI\;C:\Program Files\dotnet\;C:\Tools\vcpkg;C:\Program Files (x86)\dotnet\;C:\Users\appveyor\AppData\Local\Microsoft\WindowsApps;C:\Users\appveyor\AppData\Local\Yarn\bin;C:\Users\appveyor\AppData\Roaming\npm;C:\Program Files\Docker;C:\Program Files (x86)\Microsoft SQL Server\140\Tools\Binn\;C:\Program Files\Microsoft SQL Server\140\Tools\Binn\;C:\Program Files\Microsoft SQL Server\140\DTS\Binn\;C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\Common7\IDE\Extensions\TestPlatform;C:\Program Files (x86)\Microsoft SQL Server\110\DTS\Binn\;C:\Program Files (x86)\Microsoft SQL Server\140\DTS\Binn\;C:\Program Files\erl9.2\bin;C:\Program Files (x86)\NSIS;C:\Program Files (x86)\Yarn\bin\;C:\Tools\Octopus;C:\Program Files\PowerShell\6.0.2;C:\Program Files (x86)\Windows Kits\10\Windows Performance Toolkit\;C:\Program Files\Microsoft Service Fabric\bin\Fabric\Fabric.Code;C:\Program Files\Microsoft SDKs\Service Fabric\Tools\ServiceFabricLocalClusterManager;C:\Program Files\LLVM\bin;C:\Program Files (x86)\nodejs\;C:\Program Files\Git\cmd;C:\Program Files\Git\usr\bin;C:\ProgramData\chocolatey\bin;%JAVA_HOME%\bin;
Environment Vars (like PATH) have changed. Close/reopen your shell to
 see the changes (or in powershell/cmd.exe just type `refreshenv`).
 The install of server-jre8 was successful.
  Software installed to 'C:\tools\Java\server-jre'
elasticsearch v6.2.4 [Approved]
elasticsearch package files install completed. Performing other installation steps.
Downloading elasticsearch 
  from 'https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-6.2.4.zip'
Progress: 100% - Completed download of C:\Users\appveyor\AppData\Local\Temp\1\chocolatey\elasticsearch\6.2.4\elasticsearch-6.2.4.zip (27.75 MB).
Download of elasticsearch-6.2.4.zip (27.75 MB) completed.
Extracting C:\Users\appveyor\AppData\Local\Temp\1\chocolatey\elasticsearch\6.2.4\elasticsearch-6.2.4.zip to C:\ProgramData\chocolatey\lib\elasticsearch\tools...
C:\ProgramData\chocolatey\lib\elasticsearch\tools
PATH environment variable does not have C:\ProgramData\chocolatey\lib\elasticsearch\tools\elasticsearch-6.2.4\bin in it. Adding...
Installing service      :  "elasticsearch-service-x64"
Using JAVA_HOME (64-bit):  "C:\Progra~1\Java\jdk1.8.0"
-Xms1g;-Xmx1g;-XX:+UseConcMarkSweepGC;-XX:CMSInitiatingOccupancyFraction=75;-XX:+UseCMSInitiatingOccupancyOnly;-XX:+AlwaysPreTouch;-Xss1m;-Djava.awt.headless=true;-Dfile.encoding=UTF-8;-Djna.nosys=true;-XX:-OmitStackTraceInFastThrow;-Dio.netty.noUnsafe=true;-Dio.netty.noKeySetOptimization=true;-Dio.netty.recycler.maxCapacityPerThread=0;-Dlog4j.shutdownHookEnabled=false;-Dlog4j2.disable.jmx=true;-Djava.io.tmpdir=C:\Users\appveyor\AppData\Local\Temp\elasticsearch;-XX:+HeapDumpOnOutOfMemoryError;-XX:+PrintGCDetails;-XX:+PrintGCDateStamps;-XX:+PrintTenuringDistribution;-XX:+PrintGCApplicationStoppedTime;-Xloggc:logs/gc.log;-XX:+UseGCLogFileRotation;-XX:NumberOfGCLogFiles=32;-XX:GCLogFileSize=64m
The service 'elasticsearch-service-x64' has been installed.
Environment Vars (like PATH) have changed. Close/reopen your shell to
 see the changes (or in powershell/cmd.exe just type `refreshenv`).
 ShimGen has successfully created a shim for elasticsearch-service-mgr.exe
 ShimGen has successfully created a shim for elasticsearch-service-x64.exe
 The install of elasticsearch was successful.
  Software installed to 'C:\ProgramData\chocolatey\lib\elasticsearch\tools'
Chocolatey installed 2/2 packages. 
 See the log for details (C:\ProgramData\chocolatey\logs\chocolatey.log).
elasticsearch-service-x64 start
Command exited with code 5

Solution

  • Retry should make it more stable:

    - appveyor-retry elasticsearch-service-x64 start