最近项目用的jenkins打包出现了问题,报错如下,
·····························
·····························
<pre class="console-output" style="font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; widows: auto; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; text-decoration: none; box-sizing: border-box; white-space: pre-wrap; word-wrap: break-word; margin: 0px; caret-color: rgb(51, 51, 51); color: rgb(51, 51, 51); font-size: 13px;">Starting a Gradle Daemon (subsequent builds will be faster)
Parallel execution with configuration on demand is an incubating feature.
FAILURE: Build failed with an exception.
* What went wrong:
A problem occurred configuring root project 'Android_dev'.
> Could not resolve all dependencies for configuration ':classpath'.
> java.io.IOException: Permission denied
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
* Get more help at [https://help.gradle.org](https://help.gradle.org/)</pre>
·····························
·····························
在各种找问题,花费了不少时间。可能是关键词没有找对,在经历了九九八十一难之后。找到了线索:
I've just installed Jenkins onto Tomcat which already has other webapps running properly.
When I try to build a Maven job, it gives me an exception as below (only the relevant part of it!):
Caused by: java.io.IOException: Permission denied
at java.io.UnixFileSystem.createFileExclusively(Native Method)
at java.io.File.checkAndCreate(File.java:1704)
at java.io.File.createTempFile(File.java:1792)
at java.io.File.createTempFile(File.java:1828)
at hudson.remoting.RemoteClassLoader.createTempDir(RemoteClassLoader.java:281)
at hudson.remoting.RemoteClassLoader.makeResource(RemoteClassLoader.java:262)
at hudson.remoting.RemoteClassLoader.findResource(RemoteClassLoader.java:194)
... 31 more
After some research, it turned out that
$ ls -ald /tmp
drwxr-xr-x 8 root root 1024 2011-11-27 16:34 /tmp
Hummmm.... That's why a temporary file could not be created!
After I changed permissions to 777, all jobs started to execute as expected.
So, I have two suggestions... either one you find more convenient:
1. Make sure that temporary files are created under JENKINS_HOME/tmp, not /tmp;
2. Perform sanity checks just after installation and after a configuration screen which stresses all known configuration issues, etc... telling the user that something needs to be remediated.
问题是说,因为jenkins这个用户没有权限读取/tmp
,我之前看错误也知道是权限问题,可是不知道是哪个目录,哪个文件,什么地方的权限问题。这里说是/tmp
目录眼前一亮。
我们看下原有的权限吧;
drwx------ 3 root root 4096 Oct 12 21:17 tmp
很明显jenkins用户没有权限。我们改 /tmp
的权限吧。
chown jenkins /tmp/
修改完的结果如下:
drwx------ 5 jenkins root 4096 Oct 12 21:45 tmp
好了,我们测试下,结果有效。问题解决了。希望以后的同学遇到了,能搜索到这个文章,快速解决问题,少花费些时间。