In our current project, we are using Elasticsearch for rapid search (it is the best search engine I’ve used to date), and are using Semaphore CI for continuous integration (Semaphore is new to me, but so far it looks very good). However, since the start of the project and now, the current Elasticsearch version has changed, and our code doesn’t match the latest version. Semaphore has Elasticsearch available, but in a new (and for us incompatible) version to the one used in our project.
Medium term, we need to update the version of Elasticsearch we are using on our project, but for now we need Semaphore to work with our code. To achieve that we need to install an older version of Elasticsearch in our Semaphore environment.
So my first step was a google, but that didn’t give me an obvious answer (there were a couple of scripts, but I wasn’t sure where to put them or how to use them).
I found the solution by using Semaphore support live chat. The response was very quick and I had a work solution within minutes. Another plus point for Semaphore.
The solution was to use the following commands:
sudo bash elasticsearch-downgrade-semaphore.sh 2.4.1
These needed to be added to our Semaphore Project’s Build Settings, in the Setup section:
With that code in place we were able to set the Elasticsearch version to 2.4.1 in our Semaphore project and the problem was solved.
An update
On using the script in anger for a few days we found we were sometimes getting build failures.
userdel: user elasticsearch is currently used by process 2662
dpkg: error processing package elasticsearch (--purge):
subprocess installed post-removal script returned error exit status 8
Errors were encountered while processing:
elasticsearch
The process to purge the existing Elasticsearch files was occurring before the process had stopped. To fix this we created a modified version of the script with a 1 second pause prior to the file purge.
sleep 1
apt-get purge -y elasticsearch
This seems to have fixed the problem.