I solved this issue by adding '%M2_HOME%\bin' as a system variable. Refer How to fix maven error in jenkins on windows: ‘mvn’ is not recognized as an internal or external command