Skip to content
Advertisement

Mvn is not recognized as a command on Github Actions on Windows a self hosted runner

I set up a simple Github Actions workflow simply to check if my self-hosted Windows Virtual Machine is able to recognize the installed java/git/maven versions.

Versions in the Virtual Machine:

  • Microsoft Windows 64 bit
  • Java version: jdk1.8.0_202
  • Maven version: 3.8.5

Java and Git are correctly recognized however the step checking for maven version fails:

JavaScript

it fails with the following log:

JavaScript

Below how I set up the environmental variables on the machine:

Environment Variable Screenshot

On the machine mvn command is recognized without any problems, the issue only happens when running the Github workflow yaml. Below the .yaml script also with different attempts to set the enviroment variable from the script itself:

JavaScript

Thanks in advance to anyone suggesting a solution.

Advertisement

Answer

Solved by adding this Actions from the GitHub Marketplace inside the .yml workflow file:

https://github.com/stCarolas/setup-maven https://github.com/marketplace/actions/setup-maven

Advertisement