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 {} \;

执行完成之后再次构建项目就不会再出现以上异常了。

猜你喜欢

转载自blog.51cto.com/darren88/2401220
今日推荐