Below is the error message I'm receiving. The master is running on OpenSUSE and my Jenkins version is "Jenkins ver. 1.466.12.1 (Jenkins Enterprise by CloudBees 12.11)".
I've verified that I can create a file on the linux box in /mnt/jenkinsbackup. Is this a user permission problem?
Building on master in workspace /var/lib/jenkins/jobs/Jenkins Backup/workspace
java.io.FileNotFoundException: /mnt/jenkinsbackup/backup-Jenkins Backup-19.tar.gz (Permission denied)
at java.io.FileOutputStream.open(Native Method)
at java.io.FileOutputStream.(FileOutputStream.java:209)
at java.io.FileOutputStream.(FileOutputStream.java:160)
at com.infradna.hudson.plugins.backup.store.LocalFileStore$1._backup(LocalFileStore.java:50)
at com.infradna.hudson.plugins.backup.store.BackupFile.backup(BackupFile.java:25)
at com.infradna.hudson.plugins.backup.BackupBuilder.perform(BackupBuilder.java:95)
at hudson.tasks.BuildStepMonitor$1.perform(BuildStepMonitor.java:19)
at hudson.model.AbstractBuild$AbstractRunner.perform(AbstractBuild.java:710)
at hudson.model.Build$RunnerImpl.build(Build.java:178)
at hudson.model.Build$RunnerImpl.doRun(Build.java:139)
at hudson.model.AbstractBuild$AbstractRunner.run(AbstractBuild.java:480)
at hudson.model.Run.run(Run.java:1438)
at hudson.model.Build.run(Build.java:110)
at hudson.model.ResourceController.execute(ResourceController.java:88)
at hudson.model.Executor.run(Executor.java:239)
Build step 'Take backup' changed build result to FAILURE
Finished: FAILURE
EDIT: I forgot to mention that I am running jenkins as a daemon and not as a user.
The permission problem stemmed from the mounted network folder. Only root had permission to write to it. One suggestion I found on the internet was to change the ownership of the folder to jenkins:nogroup (since that is what the Jenkins master is running as), but you can't do that to a mounted folder.
But that led me to changing the permissions when mounting the folder in the first place. I learned I could do this:
mount -t cifs //network_folder_path/jenkins /mnt/jenkins -o username=USERNAME,password=XXXX,dir_mode=0777,file_mode=0777
That mounted the folder with write permissions for everyone and the job was able to run.
The stack trace does say permission error - so perhaps the jenkins app is running as a different user to the one you verified can read and write to that directory?
Related
getting "FATAL: Couldn’t find any executable in /root/apache-maven-3.5.3" with Jenkins version 2.107.3. I am CentOS.
Added paths of Java and Maven in .bash_profile
git rev-list --no-walk 0caf6111d5ef4679bf818f99fa448a525566ee69 # timeout=10
FATAL: Couldn’t find any executable in /root/apache-maven-3.5.3
Build step 'Invoke top-level Maven targets' marked build as failure
Finished: FAILURE
Based on the comments under the OP this is definitely a permission issue.
You cannot expect to put something in the /root path and be able to access it with a user other than root. This will most likely fail, because the permissions which are used for home directories, allow only the root user to read, write and execute things in that path.
CentOS has SELinux enforce by default and it provides additional security layer which will also prevent users from reading and/or writing to certain paths on the system. So you could actually have the "correct" permissions set for a path, but the user that's trying to read/write something there could still not be able to do it.
In general, you should be running Jenkins server and agents under a dedicated user and group - i.e jenkins user and group. This will allow you to create a path like /jenkins/ which is owned by the jenkins user & group. Then set that as the path where Jenkins installs it's tools.
I created new project and using Jenkins to build it.
So, everything is ok if I put the project in directory belongs to Jenkins user.
My config for Workspace Root Directory is:
${ITEM_ROOTDIR}/workspace
Home Jenkins user is
/Users/Shared/Jenkins/Home
However, if I change this config to use new workspace under other user home directory (in my case is /Users/apple), I receive this error:
Started by user anonymous
Building in workspace /Users/apple/Desktop/JenkinsJobs
java.io.IOException: Failed to mkdirs: /Users/apple/Desktop/JenkinsJobs
at hudson.FilePath.mkdirs(FilePath.java:1164)
at hudson.model.AbstractProject.checkout(AbstractProject.java:1268)
at hudson.model.AbstractBuild$AbstractBuildExecution.defaultCheckout(AbstractBuild.java:610)
at jenkins.scm.SCMCheckoutStrategy.checkout(SCMCheckoutStrategy.java:86)
at hudson.model.AbstractBuild$AbstractBuildExecution.run(AbstractBuild.java:532)
at hudson.model.Run.execute(Run.java:1741)
at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:43)
at hudson.model.ResourceController.execute(ResourceController.java:98)
at hudson.model.Executor.run(Executor.java:410)
Finished: FAILURE
I also tried config to this path, but it also no lucky:
${ITEM_ROOTDIR}/../../../../../../apple/Desktop/JenkinsJobs
So, how can I config to use with another checkout source directory?
Example, I checkout my source to this folder:
/Users/apple/Desktop/JenkinsJobs
and I want to use this folder as workspace, how I do it?
Thanks in advance.
We can actually see the error is with permissions:
Failed to mkdirs: /Users/apple/Desktop/JenkinsJobs
The job is failing to create the folder structure on the given location.
Your options:
Pre-create the folders and grant access to the service running the job:
sudo mkdir /Users/apple/Desktop/JenkinsJobs
(given Jenkins uses account 'jenkins') sudo chown -R jenkins:jenkins /Users/apple/Desktop/JenkinsJobs
Use a different location for your workspace which is not restricted like a user profile.
I've been scratching my head on this issue but haven't found a way around it. I've installed Jenkins on my OSX v10.8.4 using the Jenkins 1.571 installer from the Jenkins website.
It gets installed by default in /Users/Shared/Jenkins/Home folder.
I want to use Jenkins to act as a CI server for my iOS code residing on my company's perforce server. For this I created a user(matching to that of my perforce user along with the same password)on my OSX box. I also copied the P4 command line to /usr/local/bin and correctly setup the P4PORT to point to my perforce server settings. So far so good.
I verified that I was able to connect to my perforce server from command line by using the p4 login command, and it worked successfully.
I then installed the perforce plugin from Jenkins Manage plugins option (https://wiki.jenkins-ci.org/display/JENKINS/Perforce+Plugin).
Now when I create a new job and specify the settings correctly in the perforce plugin piece of the jenkins job, I always get these errors:
Started by user anonymous
Building in workspace /Users/Shared/Jenkins/Home/jobs/iosbuild/workspace
Using master perforce client: ios-jenkins
[workspace] $ p4 workspace -o ios-jenkins
Caught exception communicating with perforce. Could not run perforce command.com.tek42.perforce.PerforceException: Could not run perforce command.
at hudson.plugins.perforce.HudsonP4DefaultExecutor.exec(HudsonP4DefaultExecutor.java:90)
at com.tek42.perforce.parse.AbstractPerforceTemplate.getPerforceResponse(AbstractPerforceTemplate.java:331)
at com.tek42.perforce.parse.AbstractPerforceTemplate.getPerforceResponse(AbstractPerforceTemplate.java:301)
at com.tek42.perforce.parse.Workspaces.getWorkspace(Workspaces.java:61)
at hudson.plugins.perforce.PerforceSCM.getPerforceWorkspace(PerforceSCM.java:1615)
at hudson.plugins.perforce.PerforceSCM.getPerforceWorkspace(PerforceSCM.java:1576)
at hudson.plugins.perforce.PerforceSCM.checkout(PerforceSCM.java:892)
at hudson.model.AbstractProject.checkout(AbstractProject.java:1252)
at hudson.model.AbstractBuild$AbstractBuildExecution.defaultCheckout(AbstractBuild.java:624)
at jenkins.scm.SCMCheckoutStrategy.checkout(SCMCheckoutStrategy.java:86)
at hudson.model.AbstractBuild$AbstractBuildExecution.run(AbstractBuild.java:530)
at hudson.model.Run.execute(Run.java:1732)
at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:43)
at hudson.model.ResourceController.execute(ResourceController.java:88)
at hudson.model.Executor.run(Executor.java:234)
Caused by: java.io.IOException: Cannot run program "p4" (in directory "/Users/Shared/Jenkins/Home/jobs/iosbuild/workspace"): error=2, No such file or directory
at java.lang.ProcessBuilder.processException(ProcessBuilder.java:478)
at java.lang.ProcessBuilder.start(ProcessBuilder.java:457)
at hudson.Proc$LocalProc.(Proc.java:244)
at hudson.Proc$LocalProc.(Proc.java:216)
at hudson.Launcher$LocalLauncher.launch(Launcher.java:780)
at hudson.Launcher$ProcStarter.start(Launcher.java:360)
at hudson.plugins.perforce.HudsonP4DefaultExecutor.exec(HudsonP4DefaultExecutor.java:81)
... 14 more
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:53)
at java.lang.ProcessImpl.start(ProcessImpl.java:91)
at java.lang.ProcessBuilder.start(ProcessBuilder.java:452)
... 19 more
ERROR: Unable to communicate with perforce. Could not run perforce command.
Finished: FAILURE`
First I specified the perforce jenkins plugin to create the workspace for me and also let jenkins to manage my views, but I still got the same above error.
Following is my view map:
//depot/rombay/MarketingApplication/iOS/ianywhere/... //ios-jenkins/depot/rombay/MarketingApplication/iOS/anywhere/...
I then created a workspace using the p4v client, and then deselected letting jenkins create my workspaces and manage my views. The view map remains the same. However, I still get the same error.
My hunch is that since Jenkins is installed in the shared folder it's not able to execute the p4 command. However, I tried doing that and it opened up the clientspec in vi for me, which is I guess the expected behavior, but I still don't understand as to why it says that it can't find the p4 program to work for me.
Any help here would be deeply appreciated as I've run out of ideas as to what could possibly be I doing wrong.
No softlinks are required. Check if you have updated the Global Settings for p4. Manage Jenkins->Global Settings
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.
I have an ant file which has move and copy tasks. The source and destination locations are on the mapped network drive R:\. When I run them on the command prompt the build is successful but when I configure it as a job in Jenkins, the tasks are failing with the below console output.
BUILD FAILED
C:\Users\admin\.jenkins\jobs\CopyTask\workspace\build.xml:24: R:\dest does not exist.
Total time: 0 seconds
Build step 'Invoke Ant' marked build as failure
Finished: FAILURE
Both the standalone build and Jenkins build are under the same user credentials.
I have looked in the the questions copy in ANT throws java.io.FileNotFoundException and
Ant Copy Task: Failed to copy due to java.io.FileNotFoundException but it didn't help me solve the issue.
EDIT
Jenkins service was running under local system account and in Jenkins app, I was using "Jenkins's own user database" for Security Realm. I had created a user called "admin" with all the permissions granted. After looking in to this link, I installed Active Directory Plugin and used an administrator account credentials to start the Jenkins service. But still I am getting the below error message
BUILD FAILED
C:\Users\admin\.jenkins\workspace\CopyTask\build.xml:11:
Failed to copy C:\Users\admin\FldrToCopy\data.7z to
R:\data.7z due to failed to create the parent directory for R:\data.7z
Total time: 0 seconds
Build step 'Invoke Ant' marked build as failure
Finished: FAILURE
Obviously, the system account you're using doesn't have this mapped drive. Before copying, try to map the drive through the Windows net use command. In Jenkins, you can run this in your build steps as a shell command before you execute your Ant script.
I don't have a Windows machine in front of me, but it should look something like this:
net use R: /delete
net use R: /persistent:yes \\windows\share\path
You want to do the net use R: /delete first to remove any already existing mapping.
If this doesn't work, try this. This will help you create a mapped drive to your system account that always exist.
What user account is Jenkins running as? If it's running as the SYSTEM account, then it probably can't see the mapped drive. Take a look at Map a network drive to be used by a service for some ideas.
Or perhaps you could use the UNC path instead of the mapped drive?