Selfhosted GitLab: Runner uses default image instead of specified

I’m currently setting up GitLab including Gitlab-Runner on my own server and I’m migrating some Projects from GitLab.com to that server.

Sadly the CI-Pipelines fail as the docker-runner uses the default image I’ve specified at the installation instead of the one specified in the .gitlab-ci.yml

.gitlab-ci.yml

image: maven:latest

variables:
  MAVEN_CLI_OPTS: "-s .m2/settings.xml --batch-mode"
  MAVEN_OPTS: "-Dmaven.repo.local=.m2/repository -XX:+TieredCompilation -XX:TieredStopAtLevel=1"

cache:
  paths:
    - .m2/repository/
    - target/

stages:
  - build

build:
  stage: build
  script:
    - mvn $MAVEN_CLI_OPTS compile

CI-Log:

Running with gitlab-runner 11.3.1 (0aa5179e)
  on gitlab-runner-1 d8ccba4c
Using Docker executor with image debian:stretch-slim ...
Pulling docker image debian:stretch-slim ...
Using docker image sha256:44e19a16bde1fd0f00b8cfb2b816e329ddee5c79869d140415f4445df4da485c for debian:stretch-slim ...
Running on runner-d8ccba4c-project-18-concurrent-0 via gitlab-runner-1...
Cloning repository...
Cloning into '/builds/proj'...
Checking out 08830192 as master...
Skipping Git submodules setup
$ mvn $MAVEN_CLI_OPTS compile
/bin/bash: line 66: mvn: command not found
ERROR: Job failed: exit code 1

Am I doing anything wrong?

Solved it by specifying image version to maven:3.5.4-jdk-8 instead of maven:latest

2 Likes

Awesome, glad you got it solved, and thanks for posting the solution to help other community members!

1 Like