Some issue with docker image in yml file. unable to runmy pipeline after adding a new runner in gitlab

4/2/2020

I have configured my project to run on a pipeline Here is my .git.yml file content:

image: markhobson/maven-chrome:latest

stages:
  - flow1

execute job1:
  stage: flow1
  tags:
    - QaFunctional
  script:
    - export
    - set +e -x
    - mvn --update-snapshots --define updateResults=${updateResults}  clean test

Error after executing the pipeline :

bash: line 328: mvn: command not found
Running after_script
00:00
Uploading artifacts for failed job
00:00
ERROR: Job failed: exit status 127

Can anyone help me spot the error please ? Is that not able to load the docker image? When I use a shared runner I am able to execute the same.

-- user2852305
docker
gitlab
kubernetes

1 Answer

4/2/2020

Error you get means there is no maven installed on job executor mvn: command not found

Looks like image you specified image: markhobson/maven-chrome:latest has maven command:

# docker run markhobson/maven-chrome:latest mvn --version
Apache Maven 3.6.3 (cecedd343002696d0abb50b32b541b8a6ba2883f)

Other thing you specified is tags:

...
  tags:
    - QaFunctional
...

So when both image and tags are specified in your yaml then tags takes precedence and image is ignored.

Looks like your custom runner tagged with QaFunctional is shell runner without mvn configured.

As a solution either install mvn on QaFunctional or run job on docker runner (shared runners should do). To avoid such confusion don't specify image when you want to run your job on tagged shell runner.

-- makozaki
Source: StackOverflow