0
votes

I use Jenkins in windows 7 environment for a simple test, and run into this error.

I used maven to create a java test project in my win7 computer. I checked that the maven works by running 'mvn test' successfully. The project folder structure looks like below:

ProjectDir 
    pom.xml
    src
        test
            java
                MyTest.java
    run.bat

Then I set up Jenkins in the same machine and try to use Jenkins to control my local maven build.

In Jenkins 'source code management' option I choose 'None'. In Jenkins 'build step' option I choose 'Execute windows batch command' and use something like below:

cd /d ProjectDir
run.bat

and the content of run.bat is:

set PATH=%PATH% C:\Program Files\maven\apache-maven-3.3.3\bin
echo %PATH%
mvn test

All seems very straight forward, PATH shows it includes maven directory, but mvn is NOT recognized as a command. Jenkis console output as below:

C:\Program Files\Common Files\Microsoft Shared\Windows Live;C:\Program Files (x86)\Common Files\Microsoft Shared\Windows Live;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files\Intel\WiFi\bin\;C:\Program Files\Common Files\Intel\WirelessCommon\;C:\Program Files\Microsoft Network Monitor 3\;C:\Program Files (x86)\Windows Live\Shared;C:\Program Files (x86)\Skype\Phone\;c:\Program Files (x86)\Microsoft SQL Server\100\Tools\Binn\;c:\Program Files\Microsoft SQL Server\100\Tools\Binn\;c:\Program Files\Microsoft SQL Server\100\DTS\Binn\;C:\Program Files\maven\apache-maven-3.3.3\bin

ProjectDir>mvn test 
'mvn' is not recognized as an internal or external command,
operable program or batch file.

The only thing that's suspicious in this whole process is that the PATH env variable is not the same for Jenkins and my user account. However I compensate this by appending the maven path in Jenkins environment.

So what is the problem that mvn is still not recognized? Any ideas?

Thanks.

1
Have you checked if an mvn.bat/mvn.cmd file is in apache-maven-3.3.3/bin folder?khmarbaise
@khmarbaise Yes, mvn.cmd is in the bin folder. I tried using mvn.cmd explicitly in run.bat, not working either.user1559625
Can you post the outcome of the mvn -v in your windows command line ?appu
mvn -v Apache Maven 3.3.3 (7994120775791599e205a5524ec3e0dfe41d4a06; 2015-04-22T19:57:3 7+08:00) Maven home: C:\Program Files\maven\apache-maven-3.3.3 Java version: 1.7.0_79, vendor: Oracle Corporation Java home: C:\Program Files\Java\jdk1.7.0_79\jre Default locale: en_US, platform encoding: GBK OS name: "windows 7", version: "6.1", arch: "amd64", family: "windows"user1559625
In the shared output, maven home is Maven home: C:\Program Files\maven\apache-maven-3.3.3. While in windows, I faced issues with the directories having space in between(here Program Files). Can you try with setting PATH with quoted maven path "C:\Program Files\maven\apache-maven-3.3.3\bin"appu

1 Answers

-1
votes

check you have set "JAVA_HOME" = "C:\Program Files\Java\jdk1.7.0_60" in system variables

Thank you.