I am getting error while executing script from jenkins - jenkins

In jenkins pre-build step I select Execute shell script on remote using ssh while executing script I am getting below error
cd /home/appsusr/bin; ./removetwl.sh
[ssh] Exception:java.io.FileNotFoundException: /home/appsusr/ .ssh/id_dsa (No such file directory)
com.Jcraft.jsch.JschException:java.io.filenotfoundexception: /home/aapsusr/ .ssh/id_dsa (no such file or directory)

Is there somewhere you're specifying the path to your SSH key? Looks like you have an extra space before .ssh.

Related

issue in jenkins integration with git

i installed jenkins in c:\program files(x86)\jenkins and am trying to integrate with a helloworld java file. but when i first tried to build from jenkins, itself, its failed.
i went through this link : https://www.youtube.com/watch?v=bGqS0f4Utn4
when i compiled my java file, from the admin cmd prompt, its compiles successfully. but it failed within the jenkins console.
I created a C:\workspace folder and saved the java file, there.
what am doing wrong ? why am getting the wrong path within the console output?
am getting the below error in the console output :
`Console Output
Started by user user1
Running as SYSTEM
[EnvInject] - Loading node environment variables.
Building in workspace C:\Program Files (x86)\Jenkins\workspace\
HelloWorld
[HelloWorld] $ cmd /c call C:\Windows\TEMP\jenkins6223662388306682118.bat
C:\Program Files (x86)\Jenkins\workspace\HelloWorld>cd C:\Workspace
C:\Workspace>javac Hello.java
'javac' is not recognized as an internal or external command,
operable program or batch file.
C:\Workspace>java Hello
'java' is not recognized as an internal or external command,
operable program or batch file.
C:\Workspace>exit 9009
Build step 'Execute Windows batch command' marked build as failure
Finished: FAILURE
First, since you've installed JDK, make sure you've added in system level environment variable
Set JDK bin path in Jenkins > manage jenkins > global tools configurations > jdk installations, then try
mostly this option would help to resolve

Jenkins is not able to recognize xmlstarlet in my shell script

I have Jenkins running on my local Windows 7 machine. I am trying to use Jenkins for Salesforce deployment and have added a shell script to parse package.xml. My script uses xmlstarlet to do the parsing, but when I build the project I am getting the following error:
./modifyPackage.bash: line 9: xml: command not found
./modifyPackage.bash: line 24: unexpected EOF while looking for matching `"'
Build step 'Execute shell' marked build as failure
Finished: FAILURE
I am using the git sh.exe to execute the shell script, so I have added the below path in Shell executable.
C:\Program Files\Git\bin\sh.exe
Looks to me that Jenkins is not able to recognize the xml starlet used in shell script. I also tried adding xmlstarlet-1.6 exe file in the GIT directory, but it didn't work. How should I fix this?
Regards
Found out the problem. I needed to add the path of xml starlet as a PATH environment variable in Manage Jenkins -> Configure System -> Global Properties with key as PATH and value as $PATH:$Actual Path of xml starlet.

Jenkins cannot run program "phing" - Phing command execution failed

I'm new to jenkins and phing and having what appears to be a basic error with jenkins not being able to run my phing commands. Console log of my failed build is below. I only have one install of phing so I understand I don't need to "configure the job to choose one", I've also tried to add a PATH to my jenkins global environment variables and restarted Jenkins after adding the variables and still no go. I already have Phing in my local PATH as I can invoke the phing command anywhere. I'm also able to invoke the same phing command that jenkins does from terminal and the the build finishes. However, Jenkins' Build Now always fails. Any help would be great! thanks :)
Started by user anonymous
Building in workspace /Users/Shared/Jenkins/Home/jobs/php-template/workspace
Fetching changes from the remote Git repository
Fetching upstream changes from ssh://git#mystash.server:7999/myproject/myrepo.git
Checking out Revision 8fb6f843d6fd232cdde1684e18c455cef6f20460 (origin/master)
looking for '/Users/Shared/Jenkins/Home/jobs/php-template/workspace/build.xml' ...
use '/Users/Shared/Jenkins/Home/jobs/php-template/workspace' as a working directory.
[workspace]
$ phing -buildfile /Users/Shared/Jenkins/Home/jobs/php-template/workspace/build.xml clean try_ParallelTasks -logger phing.listener.DefaultLogger
FATAL: command execution failed.Maybe you need to configure the job to choose one of your Phing installations?
java.io.IOException: Cannot run program "phing" (in directory "/Users/Shared/Jenkins/Home/jobs/php-template/workspace"): error=2, No such file or directory
at java.lang.ProcessBuilder.start(ProcessBuilder.java:1041)
at hudson.Proc$LocalProc.<init>(Proc.java:244)
at hudson.Proc$LocalProc.<init>(Proc.java:216)
at hudson.Launcher$LocalLauncher.launch(Launcher.java:773)
at hudson.Launcher$ProcStarter.start(Launcher.java:353)
at hudson.Launcher$ProcStarter.join(Launcher.java:360)
at hudson.plugins.phing.PhingBuilder.perform(PhingBuilder.java:215)
at hudson.tasks.BuildStepMonitor$1.perform(BuildStepMonitor.java:20)
at hudson.model.AbstractBuild$AbstractBuildExecution.perform(AbstractBuild.java:804)
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:585)
at hudson.model.Run.execute(Run.java:1670)
at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:46)
at hudson.model.ResourceController.execute(ResourceController.java:88)
at hudson.model.Executor.run(Executor.java:231)
Caused by: java.io.IOException: error=2, No such file or directory
at java.lang.UNIXProcess.forkAndExec(Native Method)
at java.lang.UNIXProcess.<init>(UNIXProcess.java:135)
at java.lang.ProcessImpl.start(ProcessImpl.java:130)
at java.lang.ProcessBuilder.start(ProcessBuilder.java:1022)
... 15 more
Build step 'Invoke Phing targets' marked build as failure
To be clearer, as Cweiske pointed out, Jenkins fails the build because it cannot find the correct phing executable, as it looks for it in the wrong path (the one in the workspace).
Anyway, Jenkins search for that executable in other paths too, as the one you cited: "in my local PATH as I can invoke the phing command anywhere".
The problem with Your Local Path is that it is the YOUR and not the Jenkin's one. As Jenkins act on your Mac with its own user (jenkins, created during the installation process), so it cannot use Your Local Path.
Understood the problem, there is more than one possible solution (and i've tried them one by one with no success!), but the simpler (and the one that finally works!) is the "symlinking".
A note: please, take care of the difference between various types of "links" on Mac: SymLinks are different and not equals to Aliases or to Hard Links (http://macs.about.com/od/faq1/f/What-Are-Aliases-Symbolic-Links-And-Hard-Links-In-Mac-Os-X.htm).
Coming back, as in the usr/bin folder there are executables that each user on the mac can use, let's create a symlink into this folder to the executable you use every time, the one included in the folder in Your Local Path.
From Terminal, go to the usr/bin folder. Use the command "cd" to change the current directory and to go to the top of the root use something like:
> cd ../
With the command "pwd" you can see the complete path to the directory in which you currently are, and with the "ls" command you can list all the files and folders in it: use them to guide yourself in the folders tree.
So, assuming you already are in the usr/bin folder and assuming you are using MAMP as webserver, the command is:
> ln /Applications/MAMP/bin/php/php5.5.10/bin/phing ./phing
As you can see, the first parameter is the path to the executable you want to symlink, and the second parameter is the path to the folder in which you want to create the symlink. Don't forget to append the name of your new symlink!
Once done, try again to build with Jenkins: all should work well now... i hope!
Some troubleshooting:
1) You created the symlink in the wrong folder: use "rm" to remove a file
2) You haven't the right permissions: use "sudo" to act as a super admin
> sudo ln /Applications/MAMP/bin/php/php5.5.10/bin/phing ./phing
The directory in which the phing script is installed is not in $PATH of the jenkins user.
Symlink it into /usr/bin/, and you should be set.
From the following error message
Caused by: java.io.IOException: error=2, No such file or directory
at java.lang.UNIXProcess.forkAndExec(Native Method)
at java.lang.UNIXProcess.<init>(UNIXProcess.java:248)
at java.lang.ProcessImpl.start(ProcessImpl.java:134)
at java.lang.ProcessBuilder.start(ProcessBuilder.java:1029)
I got this "IOException when starting a process"
It seems like ProcessBuilder doesn't use the env variable PATH, so it can't find find phing
What I did is I removed Invoke Phing targets and added the Build as Execute Shell, and in Command I added /usr/local/bin/phing. and that is working for me.

Jenkins how to rename war file

I have deployed a war file in a remote machine using Jenkins. Now I want to rename the war file through jenkins before it extracts the work folder? How can this be done? I tried post deployment action -> execute shell and mv file.war to new-file.war but it returns an error saying : mv: cannot stat `file.war': No such file or directory.
Suppose there was something wrong with my path it would not even have gone to remote location. but for me, after scp' ing it to remote location thru jenkins, and when i try to do a mv, it fails.. What could the reason be??
Adding additional Step of Execute shell during Add build Step or Add post-build action stage, normal renaming shell command mv can be used to rename artifacts.
Note: Make sure use the correct path(Relative to project/workspace root)
Your mv command is probably executed in another directory than the one you are expecting.
To know the directory your script is running in without reading the jenkins / plugin documentation add
echo "pwd of script is: " `pwd`
to your shell script and inspect the output of the jenkins build - that way you can be sure about the directory the script is run in.

Jenkins not Finding CVS on Solaris

I'm trying to pull from a CVS repository from Jenkins on a Solaris box. Jenkins is running under Tomcat and CVS is on the same machine as Jenkins and Tomcat. When I try to set up a Jenkins job that pulls from CVS it fails with the following stack trace:
Building in workspace /home/tomcat/.jenkins/jobs/compile xml/workspace
cvs checkout -P -D 23 May 2013 15:49:46 -0800 -d workspace xml
ERROR: CVS Authentication failed: Connection error
org.netbeans.lib.cvsclient.connection.AuthenticationException: Connection error
at org.netbeans.lib.cvsclient.connection.LocalConnection.openConnection(LocalConnection.java:102)
at org.netbeans.lib.cvsclient.connection.LocalConnection.open(LocalConnection.java:145)
at org.netbeans.lib.cvsclient.Client$1.run(Client.java:374)
at java.lang.Thread.run(Thread.java:619)
Caused by: java.io.IOException: Cannot run program "cvs": error=2, No such file or directory
at java.lang.ProcessBuilder.start(ProcessBuilder.java:460)
at java.lang.Runtime.exec(Runtime.java:593)
at java.lang.Runtime.exec(Runtime.java:431)
at java.lang.Runtime.exec(Runtime.java:328)
at org.netbeans.lib.cvsclient.connection.LocalConnection.openConnection(LocalConnection.java:95)
... 3 more
Caused by: java.io.IOException: error=2, No such file or directory
at java.lang.UNIXProcess.forkAndExec(Native Method)
at java.lang.UNIXProcess.<init>(UNIXProcess.java:53)
at java.lang.ProcessImpl.start(ProcessImpl.java:65)
at java.lang.ProcessBuilder.start(ProcessBuilder.java:453)
... 7 more
ERROR: Cvs task failed
It looks to me that Jenkins can't find cvs. When I log in as tomcat and type cvs, the command works. If I create a job in Jenkins and run the cvs command from the shell task, the command works. If I echo environment variables, such as PATH or CVSROOT, I get the expected results.
Where does Jenkins look for cvs? How can I set its path so it can see cvs?
-Update-
This looks similar: https://issues.jenkins-ci.org/browse/JENKINS-12633 but I have cvs installed on the server
The problem ended up being that Jenkins was getting its path from tomcat and tomcat was not getting the same path as the tomcat user (I assume because I'm starting tomcat as a service). I solved this by adding the following to the beginning of catalina.sh
PATH=$PATH:/path/to/cvs
export PATH

Resources