Cannot Run Program "Mvn" Error=2, No Such File or Directory

Cannot run program mvn error=2, No such file or directory

There are multiple things here.

You either didn't select Maven version in Job configuration.
Or you didn't configure Jenkins to install a Maven version.
Or you expected to use locally installed Maven on the Slave, but it's not configured for jenkins user.

Since I don't know what you've configured (or didn't configure) and what you expected to use, I can't answer directly, but I can explain how it works.

If you want to use locally installed Maven on master/slave

  • You must have Maven locally installed
  • You must be able to launch it with jenkins user

    1. Execute sudo jenkins, and then execute mvn on your Slave to verify that jenkins user can run mvn
    2. If that fails, you need to properly install/configure Maven
  • In Job configuration, for Maven Version, you must select Default. This is the setting that uses the version that's installed locally on the node

If you want to have Jenkins install Maven for you

  • You must go to Jenkins Global Tool Configuration, and configure a Maven version with automatic installer (from the web).
  • In Job configuration, for Maven Version, you must select that particular version that you've just configured.

How can I get a Maven goal to run as Ant build.xml task? Cannot run program mvn error=2

Credit goes to dariosiciliy. Ant does not know the path to the executable of the intellij's mvn program. if I add it (or if I install maven on the system and put it into the path variable), it works.

Java, Caused by: java.io.IOException: error=2, No such file or directory

I finally found the answer, because the Process I start is different with the process of the terminal, so can't access /usr/local/bin, have to add -l to run the command as logged in user.
Runtime.getRuntime().exec(new String[]{"bash", "-l", "-c", cmd}, null, new File(f))

Error in Maven goal inside Jenkins on Docker in Windows


I have also noticed that even though the workspace is created in my
D: drive, Jenkins_home still shows up as /var/Jenkins_home in the
Jenkins config page. Please help me figure this out.

From the containers perspective, there is no D: drive, the jenkins_home will always be /var/jenkins_home inside the container.

The syntax -v //D/jenkins:/var/jenkins_home means mount D:\jenkins onto /var/jenkins_home inside the container. This will effectively just replace or backup the containers jenkins home in the jenkins folder.

The syntax -v jenkins_home://D/jenkins_workspace is not useful. It means "create" a /D/jenkins_workspace directory inside the container and use a named volume called jenkins_home to backup this folder. This is not useful.

The main problem that you have, is that maven is not installed inside the jenkins container. Thus jenkins clearly can't find it. You need to configure maven to be installed. You can do that in jenkins, by going to:

Manage Jenkins > Configure System > Maven section and then configure it to install maven automatically.

Eclipse maven plugin: Cannot run program mvn for WSO2 ESB SampleServices

Eventually find out to pay more attention to problem

SampleServices\pom.xml configure exec-maven-plugin. Important part is maven itself is called as executable

<executable>mvn</executable>
<workingDirectory>${project.build.directory}</workingDirectory>
<arguments>....

This means that mvn.bat has to be in PATH. Use variable PATH or run eclipse from cmd, but before start of application execute

 set PATH=%PATH%;c:\path-to-maven-bin-directory\

and only then

./eclipse.exe

and u will get in eclipse console

    [INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary:
[INFO]
[INFO] QueryDoctorEP ...................................... SUCCESS [ 2.855 s]
[INFO] GrandOakEP ......................................... SUCCESS [ 0.057 s]
[INFO] ClemencyEP ......................................... SUCCESS [ 0.064 s]
[INFO] PineValleyEP ....................................... SUCCESS [ 0.067 s]
[INFO] ChannelingFeeEP .................................... SUCCESS [ 0.044 s]
[INFO] SettlePaymentEP .................................... SUCCESS [ 0.051 s]
[INFO] HealthcareAPI ...................................... SUCCESS [ 0.776 s]
[INFO] PaymentRequestMessageStore ......................... SUCCESS [ 0.599 s]
[INFO] PaymentRequestProcessingSequence ................... SUCCESS [ 0.541 s]
[INFO] PaymentRequestProcessor ............................ SUCCESS [ 0.597 s]
[INFO] SampleServices_module .............................. SUCCESS [ 0.437 s]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 7.829 s
[INFO] Finished at: 2017-05-23T12:23:58+03:00
[INFO] Final Memory: 17M/209M
[INFO] ------------------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 23.775 s
[INFO] Finished at: 2017-05-23T12:23:58+03:00
[INFO] Final Memory: 12M/201M
[INFO] ------------------------------------------------------------------------

Java Process error cannot run program

new ProcessBuilder("mvn -version") does not run mvn with an argument -version, as you're intending. Instead, it tries to run a program named mvn -version. That is, the program name itself has two words and a space between them. It makes perfect sense that you don't have such a program! :-)

Notice that ProgramBuilder's constructor takes a String... argument for the program name and arguments. What you want is: new ProcessBuilder("mvn", "-version").



Related Topics



Leave a reply



Submit