jenkins迁移过程:
1.迁移tomcat以及下面的jenkins webapp
2.迁移maven以及他下载下来的私有仓库
3.迁移家目录下~/.jenkins隐藏文件夹
这里我都是通过scp方式全部发送过去,然后启动tomcat,之后发现每次打包控制台报错如下
23:01:50 由用户 admin 启动 23:01:50 ln builds/lastSuccessfulBuild /root/.jenkins/jobs/test-mall/lastSuccessful failed 23:01:50 java.nio.file.DirectoryNotEmptyException: /root/.jenkins/jobs/test-mall/lastSuccessful 23:01:50 at sun.nio.fs.UnixFileSystemProvider.implDelete(UnixFileSystemProvider.java:242) 23:01:50 at sun.nio.fs.AbstractFileSystemProvider.deleteIfExists(AbstractFileSystemProvider.java:108) 23:01:50 at java.nio.file.Files.deleteIfExists(Files.java:1165) 23:01:50 at hudson.Util.createSymlink(Util.java:1351) 23:01:50 at hudson.model.Run.createSymlink(Run.java:1933) 23:01:50 at hudson.model.Run.updateSymlinks(Run.java:1914) 23:01:50 at hudson.model.Run.execute(Run.java:1792) 23:01:50 at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:43) 23:01:50 at hudson.model.ResourceController.execute(ResourceController.java:97) 23:01:50 at hudson.model.Executor.run(Executor.java:429) 23:01:50 ln builds/lastStableBuild /root/.jenkins/jobs/test-mall/lastStable failed 23:01:50 java.nio.file.DirectoryNotEmptyException: /root/.jenkins/jobs/test-mall/lastStable 23:01:50 at sun.nio.fs.UnixFileSystemProvider.implDelete(UnixFileSystemProvider.java:242) 23:01:50 at sun.nio.fs.AbstractFileSystemProvider.deleteIfExists(AbstractFileSystemProvider.java:108) 23:01:50 at java.nio.file.Files.deleteIfExists(Files.java:1165) 23:01:50 at hudson.Util.createSymlink(Util.java:1351) 23:01:50 at hudson.model.Run.createSymlink(Run.java:1933) 23:01:50 at hudson.model.Run.updateSymlinks(Run.java:1915) 23:01:50 at hudson.model.Run.execute(Run.java:1792) 23:01:50 at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:43) 23:01:50 at hudson.model.ResourceController.execute(ResourceController.java:97) 23:01:50 at hudson.model.Executor.run(Executor.java:429) 23:01:50 构建中 在工作空间 /root/.jenkins/workspace/test-mall 中 23:01:50 > git rev-parse --is-inside-work-tree # timeout=10 23:01:50 Fetching changes from the remote Git repository 23:01:50 > git config remote.origin.url http://192.168.50.208/java/mall.git # timeout=10 23:01:50 Fetching upstream changes from http://192.168.50.208/java/mall.git
console报这个错误,但不影响job运行。原因是jenkins ln命令执行失败,将命令直接在linux中执行报错,信息为ln不能对文件夹创建硬链接
错误原因:
在scp的时候,在遇到文件链接的时候,会自动把目标文件拉去过来进行压缩,打进压缩包中;实际上在jenkins中,***/lastSuccessful是个链接文件,而经过scp、zip、unzip变成了文件夹,所以迁移后的jenkins再进行ln操作,就会出现上述的错误。
解决方法:
知道了原因,解决方法就简单了,删除所有家目录下面./jenkins/job的 ***/lastSuccessful、lastStable这两个文件夹,可以手动创建文件链接(当然也可以不创建,后续再执行job会自动生成)。
评论区