GitLab CI/CD - ERROR: Job failed: build directory needs to be an absolute path

I am trying to build and deploy a simple maven application using GitLab CI. When I try to run the pipeline, I get the following error:

ERROR: Job failed: build directory needs to be an absolute path

Please find below my .gitlab-ci.yml file

image: maven:latest

variables:
  MAVEN_CLI_OPTS: "-s .m2/settings.xml --batch-mode"
  MAVEN_OPTS: "-Dmaven.repo.local=.m2/repository"

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

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

test:
  stage: test
  script:
    - mvn $MAVEN_CLI_OPTS test

deploy:
  stage: deploy
  script:
    - mvn $MAVEN_CLI_OPTS deploy
  only:
    - master

Thanks in advance for your solutions.

Hello @aamir1993 and welcome to the GitLab Forum!

Could you please let us know what gitlab-runner version are you using? We had some issues with the previous versions, here’s the issue with more details https://gitlab.com/gitlab-org/gitlab-runner/issues/4335.

If you could upgrade it to 11.11.2, it may solve some issues.

Thanks for the reply @dsumenkovic . Now I updated my runner to 11.11.2 . Now, my runner doesn’t start at all. Any idea why this is happening?

The issue with starting the runner was because I was connected to corporate network and needed admin right. It is now working. Thanks for the reply.

Yay! I am glad to hear that you’ve managed to resolve the issue. (sorry for the delayed response).