I've just started setting up a build server, using Jenkins.
Right now i have an extremely vanilla setup. Just trying to get it to run the default target of a specific build file. However whenever i run it jenkins reports this:
[build] $ cmd.exe /C '"ant.bat -file build.xml compileReleaseBuild && exit %%ERRORLEVEL%%"'
'"java.exe"' is not recognized as an internal or external command, operable program or batch file.
Build step 'Invoke Ant' marked build as failure
Finished: FAILURE
The odd thing is, i have my PATH and JAVA_HOME enviroment variables set up correctly, and i can run this command from the command line correctly. What is it that jenkins does that is different from running the commands by hand?
As stated by gareth_bowles, Jenkins runs as the system account on your machine. This means that any permissions or configuration (like your enviroment variables) have to be set in the system context as well. (more info here on setting env as the system account)
Related
I have built an executable jar file which is also a standalone SpringBoot Application. The requirement is that I have to run this jar file from command line which also provides command line arguments which are meant to override application.properties properties and will be used further.
I have tried and this works perfectly when ran from Windows Command Prompt.
Now I further want to deploy this on jenkins and run the same jar file usign jenkins using the command:Note that the command is important since it overrides application.properties.
Will it work in jenkins? Should i go with "Execute Shell" or "Execute Windows batch command" for it in jenkins? I would be trying it but need o know .
Command: java -jar myJArName.jar --server.port=10 --another.argument=1 --another.argument=2
Yes, you can use execute shell as you mentioned above if:
Java is installed on the host that Jenkins runs on
java is part of $PATH (you can check this by running which java on your jenkins host)
myJarName.jar is actually on the host jenkins runs on
Btw. I assume Jenkins runs on a Linux host. Otherwise you might have to use Execute Windows batch command which will work in a similar way to execute shell, but I never used it.
I'm trying to install Jasperserver onto a Windows VM with Powershell.
I can install Java just fine, but some subsequent bat files that get run are complaining they can't find environment variables such as JAVA_HOME. I can see they exist however.
I add the environment variables:
[Environment]::SetEnvironmentVariable("JAVA_HOME", "C:\Program Files\Java\jdk1.8.0_91", "Machine")
[Environment]::SetEnvironmentVariable("JRE_HOME", "C:\Program Files\Java\jre1.8.0_91", "Machine")
[Environment]::SetEnvironmentVariable("CLASSPATH", "C:\Program Files\Java\jdk1.8.0_91\jre1.8.0_91\lib\rt.jar", "Machine")
And also the path variable. Going into System -> Advanced System Settings -> Environment variables I can see they are there, so I assume it's not just setting the powershell session.
When I try to run ANT (though a build in batch)
cd C:\Jaspersoft\jasperreports-server-6.2.0\apache-tomcat\bin
$arguments = '/c service.bat install'
Start-Process cmd -Wait -PassThru -ArgumentList $arguments
it gives me this error:
> WARNING: JAVA_HOME environment variable not found [minimal] Running
> install-minimal-pro Ant task
> ---------------------------------------------------------------------- '"java.exe"' is not recognized as an internal or external command,
> operable program or batch file. Checking Ant return code: OK
I've tried:
Setting the environments several ways (setx.exe, etc)
Running the bat in many ways, start-process, cmd, in an invoke-command, etc
If I reboot the server it will install fine. Also, if I run the batch directly in a command prompt it's fine.
Before I have to use an image with Java already installed, I want to understand why this is happening and ideally make it work.
Both SetEnvironmentVariable(..., "Machine") and setx set the variable in the registry. This value is used for future processes launched by explorer (such as after a reboot), but it is NOT set for the current process or its children. Your script needs to set the variables for the current process.
Using the .NET syntax:
[Environment]::SetEnvironmentVariable("JAVA_HOME", "C:\Program Files\Java\jdk1.8.0_91", "Process")
Or, using PS syntax
$env:JAVA_HOME = "C:\Program Files\Java\jdk1.8.0_91"
I am running OS X Mavericks on a MacBook Pro.
I have maven 3.0.5 installed.
When I run mvn, I am getting the following error message.
Error while executing process. Cannot run program "/bin/sh": error-2, No such file or directory
And before you ask:
PATH="/usr/local/apache-maven-3.0.5/bin:/Library/Java/JavaVirtualMachines/jdk1.7.0_79.jdk/Contents/Home/bin:/usr/local/bin:/bin:/usr/bin"
M2_HOME="/usr/local/apache-maven-3.0.5"
M2="/usr/local/apache-maven-3.0.5/bin"
MAVEN_OPTS="-Xms256m -Xmx768m -XX:MaxPermSize=512m"
I am also seeing the following near the beginning of the mvn output:
[WARNING] Some problems were encountered while building the effective settings
[WARNING] Failed to use environment variables for interpolation: Cannot run program "env": error=0, spawn failed #
I had the same problem: exec() failed with ANY executable. Finally remembered that I was using a private jre. That jre was a copy of the original one, just with bin/java set as executable.
I made lib/jspawnhelper executable and it worked!
If you are using eclipse , this is due to the java version. point java to your OS java instead of eclipse java. this will be solved
It seems your system is missing the "sh" shell to start interpreting the script.
I just looked up installed shells on Mac OSX and got this result:
/bin/zsh
/bin/ksh
/bin/tcsh
/bin/bash
/bin/sh
So when "/bin/sh" is missing, try "/bin/bash" for example.
Better:
Check if "/bin/sh" exist
If exist check if the user which runs the command can execute the shell
Because it can be possible that the shell binary exist but isn't executable for you. Then you have to make it executable for the user trying mvn.
Hope that helps ;)
I have imported an example from FMODProgrammersApi example and I have done the procedure of Cygwin and Android NDK but when i run my project it gives following error in console
14:53:34 **** Incremental Build of configuration Default for project Recording ****
bash /ndk-build all
Cannot run program "bash": Launching failed
Error: Program "bash" not found in PATH
PATH=[C:/Program Files/Java/jdk1.6.0_06/bin/../jre/bin/client;C:/Program Files/Java/jdk1.6.0_06/bin/../jre/bin;C:/Program Files/Java/jdk1.6.0_06/bin/../jre/lib/i386;C:\Windows\system32;C:\Windows;C:\Windows\system32\Wbem;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files\Intel\OpenCL SDK\2.0\bin\x86;C:\Program Files\Java\jdk1.6.0_06\bin;D:\ABHIJEET_ONYX\New_Android_Sdk\adt-bundle-windows-x86-20140321\eclipse;]
14:53:35 Build Finished (took 267ms)
Please help me ...
I have gone through this tutorial http://mindtherobot.com/blog/452/android-beginners-ndk-setup-step-by-step/
There is no bash command in Windows platforms by default.
You can install a git which has one bash command and set the git bin folder (such as C:\Program Files (x86)\Git\bin) into system/user's path environment
I have a unix machine running Jenkins master, and I have also configured a windows slave. That works nice. But when I run a groovy script using the groovy plugin (in option system groovy script), and use a java.lang.ProcessBuilder to run a maven command, I get this:
Caused by: java.io.IOException: java.io.IOException: error=2,
No such file or directory
at java.lang.UNIXProcess.<init>(UNIXProcess.java:148)
at java.lang.ProcessImpl.start(ProcessImpl.java:65)
at java.lang.ProcessBuilder.start(ProcessBuilder.java:453)
... 122 more
Build step 'Groovy Postbuild' marked build as failure
Finished: FAILURE
And the directory which the exception says doesn't exist, actually exists.
So my question is how can I start a maven command using groovy script on a windows slave when the master is running on a unix slave?
I find it speculative why I get the exception java.lang.UNIXProcess when I am running the groovy script on windows (the script file itself is located on the same machine as the windows slave, and I also checked from System.getEnv() that JAVA_HOME is correct)