我正在运行最新版本的Jenkins (v 1.563)
和Node (0.10.28)
。
我有一个构建良好的Java项目。
当我将预构建步骤添加为节点脚本(将Provide Node& npm bin /文件夹添加到PATH中)时,我收到以下错误,尽管我已经为所有内容(node,tomcat,jenkins)提供了777权限。
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....
构建步骤"执行NodeJS脚本"标记为失败。
当我删除nodejs步骤时,它构建正常。
我的脚本很简单,
node --version
grunt --version
bower --version
完全错误:
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
答案 0 :(得分:2)
修正了没有sudo的问题;我想在root下运行 Jenkins 非常不安全。
以下是工作设置:
/var/lib/jenkins/tools
应归jenkins:jenkins
所有:
drwxr-xr-x 6 jenkins jenkins 4096 May 12 15:12 tools
如果您需要全局安装任何nodejs软件包(例如, grunt ),更简单的方法是避免jenkins窗口全局npm软件包安装(它将需要root权限),但在linux控制台中运行:
sudo npm install -g grunt
它将为所有人安装 grunt , Jenkins 将能够在构建过程中使用它。
答案 1 :(得分:1)
我通过使用sudo运行Tomcat来解决问题。请记住创建一个setenv.sh文件(在Tomcat documentation中阅读有关setenv的更多信息)。在使用sudo运行tomcat之前,请记住在setenv中设置HOME_JRE。