Jenkins遷移jobs後項目構建出現java.nio.file.DirectoryNotEmpt

1、首先說一下遷移過程
1)新環境部署Jenkins持續集成環境,這裏不在詳細說明安裝過程;
2)直接把舊的Jenkins家目錄下得jobs目錄通過scp得方式進行傳輸到新得環境下;

遷移完成後啓動新環境Jenkins服務,構建項目控制檯輸出如下:

Jenkins遷移jobs後項目構建出現java.nio.file.DirectoryNotEmpt

觀察控制檯輸出到最後,項目是構建成功得,而且不影響運行。

2、錯誤原因
通過Google查找得知有人提交了這個issues,This started happening on a new Jenkins server that a teammate was trying to setup by cloning an existing one, and I found out that he used scp -r to copy the whole working tree and that resulted in the lastSuccessful and lastStable soft-links to get converted to physical directories. I guess Jenkins was trying to remove it like it is a file (which a soft-link is), but since it turned out to be a directory that is not empty, it is causing this exception. When you remove/rename these directories, it clears the path for Jenkins to recreate the soft-links thus solving the problem. 鏈接詳情請移步到:https://issues.jenkins-ci.org/browse/JENKINS-21330
翻譯如下:
這開始發生在一個新的Jenkins服務器上,隊友試圖通過克隆現有的服務器來設置,我發現他使用scp -r來複制整個工作樹,這導致了lastSuccessful和lastStable軟鏈接轉換爲物理目錄。我猜Jenkins試圖刪除它,就像它是一個文件(軟鏈接),但由於它原來是一個非空的目錄,它導致了這個異常。當您刪除/重命名這些目錄時,它會清除Jenkins重新創建軟鏈接的路徑,從而解決問題。

3、解決問題
以上我們知道問題所在就很方便得解決問題了,首先登陸到新環境下,刪除所有項目得 lastSuccessful 和 lastStable目錄:

find jobs/ -type d \( -name "lastSuccessful" -o -name "lastStable" \)  -exec rm -rf {} \;

執行完成之後再次構建項目就不會再出現以上異常了。

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