Jenkins / Java intermittently can't find rake using rvm plugin - java

This is the most annoying problem because it's intermittent.
My Jenkins task updates a Ruby/Rails repository, and runs tests on it. I'm using the RVM plugin, and the rvm-managed environment is specified and exists.
Yet periodically, the task will fail with:
java.io.IOException: Cannot run program "/var/lib/jenkins/.rvm/rubies/ruby-1.9.3-p125/bin/rake" (in directory "<http://jenkins.example.net/job/test_cms/ws/")>: java.io.IOException: error=2, No such file or directory
I can repeat the job run and it will succeed. The program does in fact exist at the path specified in the error message.
Any suggestions?

I haven't used the RVM plugin. I run my Jenkins server with RVM installed system-wide and Jenkins picks it up in its path. You might give that a try if you can't get your current setup fixed.

Related

package org.junit does not exist

I am using Jenkins, and using a Github repo as Source Code.
In the Build section, I am executing this as a Windows Batch command:
set path=%path%;C:\Program Files\Java\jdk1.8.0_144\bin
cd \Users\harr\JenkinsServer\JenkinsTest\src
javac SimpleTest.java //Error is after this executes
java SimpleTest
I know it has something to do with classpath, but I am unsure how to solve this problem in jenkins.
Let me know if more information would be helpful.
Suppose you deploy the jekins server on linux platform, so you have to install the jdk, tomcat and so on, set the env path as well. Then you don't have to execute set path before every build.
you can create a script and copy the command into it, then when jenkins performs the build task, it can execute the script. Refer to the jenkins tutorial to learn about it.

Problems about Jenkins running remote shell script

I have some question when using jenkins.
the scenario:
I have installed a tomcat on machine A,and config all necessary environment including JDK, and they work well.
I wrote a shell script named restart.sh to kill the tomcat process,and restart.
I execute the script and it works well.When I check the tomcat process using ps -ef,and it shows the exact JDK path as I already config.The JDK path is /usr/local/java/JDK7
When I execute the restart.sh script via jenkins,problem comes. I can see the tomcat process using the wrong JDK path,/usr/bin/java,not the path as i config. I use SSH Publishers plugin to run the remote script.see as the image below:
enter image description here
I don't know how this problem happen,please help,Thanks all
This might be the problem of path variables, just to cross verify , find JAVA_HOME on your server 1. By logging onto server manually 2. From Exec command of your ssh section of your jenkins job , most probably you will find the answer.
i'm assuming you're jenkins is configured to use jdk which is defined at its root level.
if this didn't solve , we need to look into this problem from another angle.

Ant not running under new Jenkins config

I am re-setting up Jenkins 1.5888 on our Mac OS X box. I have googled much about this problem and have come up with the following steps.
I upgraded all plugins as requested.
From Configure System, I set up the Ant plugin to automatically download from the Apache site. I have called this installation Default.
I added and invoke ant step to my build. I selected Default a my ant installation
I ran the build. Here is the part of the output that is causing my frustration:
[participant-test] $ ant -file build.xml clean emma debug install test
FATAL: command execution failed.Maybe you need to configure the job to choose one of your Ant installations?
java.io.IOException: Cannot run program "ant" (in directory "/Users/bob/.jenkins/jobs/participant/workspace/participant-test"): error=2, No such file or directory
at java.lang.ProcessBuilder.start(ProcessBuilder.java:1047)
at hudson.Proc$LocalProc.(Proc.java:244)
at hudson.Proc$LocalProc.(Proc.java:216)
at hudson.Launcher$LocalLauncher.launch(Launcher.java:803)
at hudson.Launcher$ProcStarter.start(Launcher.java:381)
at hudson.Launcher$ProcStarter.join(Launcher.java:388)
at hudson.tasks.Ant.perform(Ant.java:217)
at hudson.tasks.BuildStepMonitor$1.perform(BuildStepMonitor.java:20)
at hudson.model.AbstractBuild$AbstractBuildExecution.perform(AbstractBuild.java:770)
at hudson.model.Build$BuildExecution.build(Build.java:199)
at hudson.model.Build$BuildExecution.doRun(Build.java:160)
at hudson.model.AbstractBuild$AbstractBuildExecution.run(AbstractBuild.java:533)
at hudson.model.Run.execute(Run.java:1759)
at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:43)
at hudson.model.ResourceController.execute(ResourceController.java:89)
at hudson.model.Executor.run(Executor.java:240)
Caused by: java.io.IOException: error=2, No such file or directory
at java.lang.UNIXProcess.forkAndExec(Native Method)
at java.lang.UNIXProcess.(UNIXProcess.java:184)
at java.lang.ProcessImpl.start(ProcessImpl.java:130)
at java.lang.ProcessBuilder.start(ProcessBuilder.java:1028)
... 15 more
Build step 'Invoke Ant' marked build as failure
I can run ant from the command line just fine for the same exact build. I've been at this for a day. I've found some similar issues that appear to be for older versions of Jenkins and don't seem to apply.
The exception seems to be because of missing Ant Home in the job configuration .. check if you have one ? And before executing from Jenkins also check if you are able to invoke ant commands from command line
In the end, we just kept trying things until it worked. The automatic install appears not to have been working.
I installed the JDK automatically. I'm not sure that part of the problem with ant was no java inside of Jenkins.
I then manually downloaded ant from the apache site and installed it within the .jenkins directory in the build user's home directory under tools. I added the ANT_HOME environment variable, added it to my path, and rebooted to make sure everything had it.
I pointed the manually configured ant to this above home directory and then pointed my build to this configuration. I believe this combination is what fixed my issue.
In my case I was running incompatible java version.
Jenkins requires Java in order to run, however yum install jenkins does not enforce that java is already installed. Check to make sure that you already have java installed by running java -version. To further make things difficult for CentOS users, the default CentOS version of Java is not compatible with Jenkins. Jenkins typically works best with a Sun implementation of Java, which is not included in CentOS for licensing reasons.
If you get output similar to the following, it means you're using the default (GCJ) version of Java, which will not work with Jenkins:
Remove old java version: # yum remove java
Install new version : # yum install java-1.7.0-openjdk

Executing windows batch script on Jenkins

I am building a project using Maven and using Jenkins for continuos integration. After the maven build i am getting an executable jar in my target folder which i am trying to run using a windows batch command as build step. But when i put the command in the box under execute windows batch command i get the following error
"cmd /c call /tmp/hudson2033384960131825453.bat FATAL: command
execution failed java.io.IOException: Cannot run program "cmd" (in
directory "/hosting/workspace/myProject"): error=2, No such file or
directory""
I am using mac OSX 10.9.3. The jenkins is deployed in a remote server which i don't have access to.
I want to execute this jar file as a build process. How can i do it?
You should not be expecting a windows batch command to be able to run on a mac. Jenkins is pretty cool, I agree, but it isn't magical.
Also, yes, it is a little confusing that the option is available to you even though you are on a Mac, but its there incase you have a linux / mac master with windows slave: https://issues.jenkins-ci.org/browse/JENKINS-17010?page=com.atlassian.streams.streams-jira-plugin:activity-stream-issue-tab
You cannot execute a windows batch command on mac or linux, end of story.
You are trying to launch windows command through jenkins on another operating system which is not going to work

Code run by Hudson can't find executable on the command line

I'm setting up my first job in Hudson, and I'm running into some problems. The job monitors two repositories, one containing our DB setup files, the other a bit of code that validates and tests the DB setup files.
Part of the code that runs will throw the validated setup files at PostgreSQL, using the psql command line tool, using Runtime.exec(). This code works perfectly on my machine, but when Hudson executes it (different machine) I get the following error:
java.io.IOException: Cannot run program "psql": CreateProcess error=2, The system cannot find the file specified
psql.exe is on the path, and I can execute it by typing the whole thing at the command line, from the same place Hudson is executing the code. The file that's meant to be passed into psql exists.
Any ideas?
I find that you need to have the programme in the path when you launch hudson or the slave. Despite having the ability to set the path in hudson it doesn't seem to work. You could also put the full path in the command, which is really a good idea from a security perspective anyway.

Categories

Resources