I tried to use the elasticsearch service in gitlab -ci by adding:
image: python:3.6
services:
- elasticsearch:2.4
in my .gitlab-ci.yml
Unfortunately it doesn't seem to work (I cannot a connection refused on http://127.0.0.1:9200/). Any idea?
I also tried to launch the docker image with:
test:
script:
- docker run -d elasticsearch
But docker
is not present...
For Elasticsearch 7, a working config looks like this:
test-elasticsearch:
stage: test
services:
- name: "docker.elastic.co/elasticsearch/elasticsearch:7.10.1"
alias: "elasticsearch"
command: [ "bin/elasticsearch", "-Expack.security.enabled=false", "-Ediscovery.type=single-node" ]
script:
- curl "http://elasticsearch:9200/_cat/health"
However, you can also have a look whether there is an embedded elasticsearch available for your runtime, e.g. for Java there are "testcontainers": https://www.testcontainers.org/modules/elasticsearch/. That way it's also easier to run tests locally for devs, since they don't need to worry about spinning up elasticsearch first.
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