简体   繁体   English

Jenkins从Workspace中删除文件

[英]Jenkins delete files from Workspace

I have jenkin's job, which copy tar file from linux user folder and then copy binary file (compiled) from another job and make new tar file. 我有jenkin的工作,从linux用户文件夹复制tar文件,然后从另一个工作复制二进制文件(编译)并创建新的tar文件。 Then jenkins user can copy that new tar file from jenkin's workspace. 然后jenkins用户可以从jenkin的工作区复制新的tar文件。 It doesn't build anything or take files from SCM. 它不构建任何东西或从SCM获取文件。 Then after a while, suddenly tar file has been deleted from workspace, I have to run job again. 然后过了一会儿,突然tar文件已从工作区中删除,我必须再次运行作业。 How I can prevent that? 我怎么能阻止这个?

You really shouldn't rely on your workspace existing after a job has completed, as the workspace can be overwritten by another build starting, or when someone deletes a build, by a slave going offline, etc... 在作业完成后,你真的不应该依赖你的工作空间,因为工作区可以被另一个构建开始覆盖,或者有人删除构建,奴隶离线等等......

Since you want to save the file for later use, you should use the "Archive the artifacts" option in your job's post-build configuration. 由于您要保存文件以供以后使用,因此应在作业的构建后配置中使用“归档工件”选项。 If you enter **/*.tar , for example, Jenkins would save all TAR files at the end of the build. 例如,如果输入**/*.tar ,Jenkins将在构建结束时保存所有TAR文件。

Then you can use Jenkins' permalinks to access the artifacts, eg: 然后你可以使用Jenkins的永久链接来访问工件,例如:
http://JENKINS/job/JOB_NAME/lastSuccessfulBuild/artifact/bin/my-app.tar

As the URL suggests, this would give you the file from the last successful build. 如URL所示,这将为您提供上次成功构建的文件。


As a sidenote, if you then want to copy archived files to another build, the best way to do this is with the Copy Artifact plugin . 作为旁注,如果您希望将归档文件复制到另一个版本,最好的方法是使用Copy Artifact插件

That way Jenkins handles the file copying for you, even across multiple Jenkins slaves, and you don't have to do anything nasty like hard-coding paths to other Jenkins workspaces. 这样Jenkins就可以为你处理文件复制,即使是在多个Jenkins从属服务器上也是如此,你不必做任何令人讨厌的事情,比如硬编码到其他Jenkins工作区的路径。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM