A
A
Anton2018-09-12 08:35:12
GitLab
Anton, 2018-09-12 08:35:12

Does service in gitlab ci start the service itself or just make a reference to it?

I'm trying to transfer gitlab ci to store images in Nexus
Gitlab-ci.yaml shortened. Left the most important

variables:
  ARTIFACT_NAME: ${CI_PROJECT_NAME}-${CI_JOB_NAME}
  build_img: maven
  pgsql_img: postgres:9.6
  MAVEN_OPTS: "-Djava.awt.headless=true -Dmaven.repo.local=./.m2/repository"
  MAVEN_CLI_OPTS: "-s .m2/settings.xml --batch-mode --errors --fail-at-end --show-version"
  REF_NAME: 9-devs
  JOB_NAME: dev
  PG_SERVER: "db-$CI_COMMIT_REF_SLUG-postgresql"
  PG_PORT: "5432"
  PG_DB: "XXXXX"
  PG_USER: "XXXXX"
  PG_PASS: "XXXX"

stages:
  - build
  - test

build:
  stage: build
  image: "$build_img"
  artifacts:
    paths:
    - assembly/target
    expire_in: 1 day
  script:
    - '/var/lib/apache-maven/bin/mvn clean package -Dmaven.test.skip=true -P main -s .m2/settings.xml'

it_unit_test:
  stage: test
  image: "$build_img"
  dependencies:
    - build
  services:
    - name: "$pgsql_img"
      alias: db
  script:
    - id
    - docker ps     || echo $?
    - ping -c 1 db  || echo $?
    - /var/lib/apache-maven/bin/mvn test -P intTests -s .m2/settings.xml

Where the error says:
$ id
uid=502(gitlab-runner) gid=501(gitlab-runner) groups=501(gitlab-runner),502(docker)
$ docker ps     || echo $?
CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS              PORTS               NAMES
$ ping -c 1 db  || echo $?
ping: db: Name or service not known
2

where there is no error writes
$ docker ps     || echo $?
/bin/bash: line 87: docker: command not found
127
$ ping -c 1 db  || echo $?
PING db (XXXXXXX): 56 data bytes
64 bytes from XXXXXXX: icmp_seq=0 ttl=64 time=0.142 ms

Question:
Does service in gitlab ci start the service itself or just make a reference to it?
How can this be debugged? correct the error?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Anton, 2018-09-12
Patsev @chemtech

What is interesting is that with such a config.
Didn't work if Shell runner was used.
It worked when I ran it in docker

it_unit_test:
  stage: test
  image: "$build_img"
  dependencies:
    - build
  services:
    - name: "$pgsql_img"
      alias: db
  script:
    - docker ps     || echo $?
    - ping -c 1 db  || echo $?
    - mvn test -P intTests
  tags:
    - docker-only

Decided
The conclusion is this.
$ ping -c 1 db  || echo $?
/bin/bash: line 93: docker: command not found
PING db (XXXXXX) 56(84) bytes of data.
64 bytes from XXXXX (XXXXX): icmp_seq=1 ttl=64 time=0.192 ms

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question