Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using redis with Gitlab CI

I am currently using serverless framework and setting up gitlab ci using shared runner.

Following is my gitlab-ci.yml:

image: node:latest

services:
  - redis

cache:
  paths:
    - node_modules/
    - java/

stages:
  - build
  - test
  - review
  - staging
  - production

build:
  stage: build
  script:
      - npm install
  artifacts:
    paths:
      - node_modules/

install:java:
  stage: build
  script:
      - apt-get update
      - apt-get install -y default-jre default-jdk openjdk-7-jre openjdk-7-jdk
      - apt-get update
      - sls dynamodb install
  artifacts:
    paths:
      - java/

connect:
  image: redis
  script:
  - redis-cli -h redis PING

unit test:
  stage: test
  script:
    - sls dynamodb start
    - babel-node ./aws/createDB.js
    - npm run unit
  dependencies:
    - build
    - install:java

unit test job requires redis and is not able to connect. Following error gets thrown, when unit test job starts:

Error while creating redis client: Error: Redis connection to 127.0.0.1:6379 failed - connect ECONNREFUSED 127.0.0.1:6379

Can someone point out what's wrong with current config file, thanks!

like image 204
ankit Avatar asked Oct 25 '17 09:10

ankit


People also ask

Does GitLab use Redis?

GitLab uses Redis for the following distinct purposes: Caching (mostly via Rails. cache ). As a job processing queue with Sidekiq.

How do I interact with Redis?

To start Redis client, open the terminal and type the command redis-cli. This will connect to your local server and now you can run any command. In the above example, we connect to Redis server running on the local machine and execute a command PING, that checks whether the server is running or not.

How does Redis-CLI work?

It has two main modes: an interactive Read Eval Print Loop (REPL) mode where the user types Redis commands and receives replies, and a command mode where redis-cli is executed with additional arguments and the reply is printed to the standard output.

What is Redis Sentinel?

Redis Sentinel is the high-availability solution for open-source Redis server. It provides monitoring of all Redis nodes and automatic failover should the master node become unavailable. This guide provides a sample configuration for a three-node Redis cluster.


1 Answers

The host address of the redis service is redis not 127.0.0.1 or localhost.

So make sure you set the host for the redis service to redis in all of your scripts and configuration files.

like image 107
Jawad Avatar answered Sep 24 '22 01:09

Jawad