Jenkins artifact plugin does not archive empty directories

倖福魔咒の 提交于 2019-12-07 14:18:14

问题


I use the Jenkins artifact plugin to downward streams to use. My problem is that despite all my efforts, empty folders are not being archived. Apparently .svn files are also not archived.


回答1:


Firstly, you are correct — empty directories cannot be archived, as a directory doesn't really make sense as an artifact in Jenkins.

If you're copying the artifacts to another job, you can just create the directory in the other job, or ensure the directory is archived in the first place by adding a .keep file (or so) and adding **/.keep to your list of artifacts to archive.


Regarding your second point that .svn files or directories are not archived, that is also correct since the default behaviour is to exclude certain patterns (e.g. .git, *~) when archiving artifacts.

To disable this behaviour, click on the Advanced… button below the "Archive the artifacts" post-build step, and uncheck the "Use default excludes" option. Then your .svn artifacts can be archived.




回答2:


same issue here, I come up with a workaround less agressevely if compared with a compressing and then stashing it.

sh "find ${env.WORKSPACE} -type d -empty -exec touch {}/.empty \;" stash name: "src", useDefaultExcludes: false, allowEmpty: true

Then later on, to unstash do the folow: unstash "src" sh "find ${env.WORKSPACE} -type f -name .empty -exec rm {} \+"

Basically any empty diretories is added an empty file called .empty, then after unstash we just remove then. I understand is uggly once the plugin should handle properly what is requested, however until the ticket below get resolved, I have to move on.

https://issues.jenkins-ci.org/browse/JENKINS-9146



来源:https://stackoverflow.com/questions/30076769/jenkins-artifact-plugin-does-not-archive-empty-directories

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!