【问题标题】:Using redis with Gitlab CI在 Gitlab CI 中使用 redis
【发布时间】:2017-10-25 09:01:34
【问题描述】:

我目前正在使用无服务器框架并使用共享运行器设置 gitlab ci。

以下是我的 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

单元测试作业需要 redis 并且无法连接。当单元测试作业开始时,会引发以下错误:

创建 redis 客户端时出错:错误:Redis 连接到 127.0.0.1:6379 失败 - 连接 ECONNREFUSED 127.0.0.1:6379

谁能指出当前配置文件有什么问题,谢谢!

【问题讨论】:

  • 下面的答案是正确的,但是如果您已经将其纳入帐户,则您可能没有正确设置您的 redis 凭据(例如:您正在传递一个配置对象并且主机密钥是错位)。如果没有找到凭据,大多数库默认为 127.0.0.1:6379,这也解释了您的错误

标签: redis continuous-integration gitlab gitlab-ci gitlab-ci-runner


【解决方案1】:

redis服务的主机地址是redis而不是127.0.0.1或者localhost

因此,请确保在所有脚本和配置文件中将 redis 服务的主机设置为 redis

【讨论】:

猜你喜欢
  • 1970-01-01
  • 2019-08-19
  • 2018-08-31
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2019-07-02
  • 2018-02-26
  • 2019-07-08
相关资源
最近更新 更多