Gitlab Runner for windows Shell cannot find mvn command

I have gitlab runner running and configured for windows “Shell executor”. My gitlab-ci.yml just has 1 job which is to run “mvn verify”. The executor is running on my local PC.

It does clone the git project which means it can find the “git” command but I get this error for mvn verify.
$ mvn verify
‘mvn’ is not recognized as an internal or external command,
operable program or batch file.

I have M2 and M2_HOME set as system level environment variables and I have verified the “mvn verify” runs normally when I do it using gitbash, powershell or windows batch. Its only gitlab runner that is having issue finding commands like “mvn”, “export”, “whereis” etc.

Fixed this issue. The M2 and M2_HOME were on the PATH at user level. Once I added them to SYSTEM level it started to work.

1 Like