1

Trying to build a maven proj in gitlab. I m trying to use gitlab runner image as my runner. Registered the runner to my gitlab project , still not able to get the maven build. It fails everytime. Registered the runner with specific tags as well yet the job doesnt pick up the runner. help

  • Can you add more details: what is the exact error message you see? The register command used? The GitLab , Maven and Docker version? The OS used? – VonC Jun 19 '22 at 04:47

1 Answers1

1

It depends on your .gitlab-ci.yml and how it fails.

For instance, from this article, you could see an mvn: not found error due to the lack of the proper Docker image used by the runner to execute the mvn command.

A possible GitLab CI CD Maven example would be something like:

image: maven:3.6-jdk-8
variables:
  MAVEN_CLI_OPTS: "-s .m2/settings.xml --batch-mode"
  MAVEN_OPTS: "-Dmaven.repo.local=.m2/repository -Dmaven.artifact.threads=50"
cache:
  paths:
    - .m2/repository/
build:
  stage: build
  script:
    - mvn clean $MAVEN_CLI_OPTS $MAVEN_OPTS deploy -DskipTests

A more complete example: gitlab/ci/templates/Maven.gitlab-ci.yml

You can see a gitlab-runner register example here:

gitlab-runner register \
--executor="docker" \
--custom_build_dir-enabled="true" \
--docker-image="maven:3.6.1-jdk-11" \
--url="http://gitlab:80" \
--clone-url="http://gitlab:80" \
--registration-token="vWtwwQgdPSEzTPNTGZnq" \
--description="docker-runner" \
--tag-list="docker" \
--run-untagged="true" \
--locked="false" \
--docker-network-mode="gitlabnetwork" \
--cache-dir="/cache" \
--docker-disable-cache="true" \
--docker-volumes="gitlab-runner-builds:/builds" \
--docker-volumes="gitlab-runner-cache:/cache" \
--docker-privileged="true" \
--docker-volumes="/var/run/docker.sock:/var/run/docker.sock"
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250