Answer the question
In order to leave comments, you need to log in
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
$ 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
$ 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
Answer the question
In order to leave comments, you need to log in
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
$ 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 questionAsk a Question
731 491 924 answers to any question