Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Jenkins And NodeJS Plugin - Permission Denied Error=13

I'm running the latest version of Jenkins (v 1.563) and Node (0.10.28).

I have a Java project that builds fine.

When I add a pre build step as a node script ( with Provide Node & npm bin/ folder to PATH checked), I get the following error although I have given 777 permissions to everything (node, tomcat, jenkins).

FATAL: command execution failed java.io.IOException: 
Cannot run program "/home/sam/Apps/apache-tomcat-8.0.5/temp/hudson5090518537487301688.js"
(in directory "/home/sam/.jenkins/jobs/WhiteSwan/workspace"): 
error=13, Permission Denied....

Build step "Execute NodeJS Script" marked build as failure.
When I remove the nodejs step, it builds fine.
My Script is simple,

node --version
grunt --version
bower --version

Full Error:

Checking out Revision e90d7b870646165dba30bd1a663644c0292e9844 (origin/master)
 > git config core.sparsecheckout
 > git checkout -f e90d7b870646165dba30bd1a663644c0292e9844
 > git rev-list e90d7b870646165dba30bd1a663644c0292e9844
[workspace] $ /home/sam/Apps/apache-tomcat-8.0.5/temp/hudson5090518537487301688.js

FATAL: command execution failed
java.io.IOException: Cannot run program "/home/sam/Apps/apache-tomcat-8.0.5/temp  /hudson5090518537487301688.js" (in directory "/home/sam/.jenkins/jobs/WhiteSwan   /workspace"): error=13, Permission denied

at java.lang.ProcessBuilder.start(ProcessBuilder.java:1042)
at hudson.Proc$LocalProc.<init>(Proc.java:244)
at hudson.Proc$LocalProc.<init>(Proc.java:216)
at hudson.Launcher$LocalLauncher.launch(Launcher.java:775)
at jenkins.plugins.nodejs.tools.DecoratedLauncher.launch(DecoratedLauncher.java:49)
at jenkins.plugins.nodejs.tools.NpmPackagesBuildWrapper$2.launch(NpmPackagesBuildWrapper.java:88)
at hudson.Launcher$ProcStarter.start(Launcher.java:355)
at hudson.Launcher$ProcStarter.join(Launcher.java:362)
at jenkins.plugins.nodejs.NodeJsCommandInterpreter.perform(NodeJsCommandInterpreter.java:84)
at jenkins.plugins.nodejs.NodeJsCommandInterpreter.perform(NodeJsCommandInterpreter.java:42)
at hudson.tasks.BuildStepMonitor$1.perform(BuildStepMonitor.java:20)
at hudson.model.AbstractBuild$AbstractBuildExecution.perform(AbstractBuild.java:745)
at hudson.maven.MavenModuleSetBuild$MavenModuleSetBuildExecution.build(MavenModuleSetBuild.java:909)
at hudson.maven.MavenModuleSetBuild$MavenModuleSetBuildExecution.doRun(MavenModuleSetBuild.java:676)
at hudson.model.AbstractBuild$AbstractBuildExecution.run(AbstractBuild.java:518)
at hudson.model.Run.execute(Run.java:1706)
at hudson.maven.MavenModuleSetBuild.run(MavenModuleSetBuild.java:529)
at hudson.model.ResourceController.execute(ResourceController.java:88)
at hudson.model.Executor.run(Executor.java:231)

Caused by: java.io.IOException: error=13, Permission denied
at java.lang.UNIXProcess.forkAndExec(Native Method)
at java.lang.UNIXProcess.<init>(UNIXProcess.java:187)
at java.lang.ProcessImpl.start(ProcessImpl.java:134)
at java.lang.ProcessBuilder.start(ProcessBuilder.java:1023)
... 18 more

Build step 'Execute NodeJS script' marked build as failure
Finished: FAILURE
like image 567
SamTheGoodOne Avatar asked Oct 21 '22 08:10

SamTheGoodOne


2 Answers

Fixed it without a sudo; I suppose that running Jenkins under root is very unsafe.

Here are the working settings:

enter image description here /var/lib/jenkins/tools should be owned by jenkins:jenkins:

drwxr-xr-x   6 jenkins jenkins      4096 May 12 15:12 tools

If you need any nodejs package installed globally (for example, grunt), the easier way is to avoid jenkins window Global npm packages to install (it will need root permissions), but run this in linux console:

sudo npm install -g grunt

It will install grunt for everyone and Jenkins will be able to use it during building process.

like image 81
riverfall Avatar answered Oct 23 '22 01:10

riverfall


I fixed the problem by running Tomcat with sudo. Please remember to create a setenv.sh file ( read more about setenv in the Tomcat documentation). Remember to set HOME_JRE in setenv before running tomcat with sudo.

like image 41
SamTheGoodOne Avatar answered Oct 23 '22 01:10

SamTheGoodOne