jenkins 打包Android 錯誤問題

最近項目用的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

好了,我們測試下,結果有效。問題解決了。希望以後的同學遇到了,能搜索到這個文章,快速解決問題,少花費些時間。

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章