在使用jenkins时,常常会问到文件怎么存储?node
正好jenkins有一个stash的功能,下面简单介绍下:ide
先看看官方是怎么解释的:测试
stash: Stash some files to be used later in the build Saves a set of files for use later in the same build, generally on another node/workspace.
Stashed files are not otherwise available and are generally discarded at the end of the build.
Note that the stash and unstash steps are designed for use with small files.
For large data transfers, use the External Workspace Manager plugin, or use an external repository manager such as Nexus or Artifactory.
This is because stashed files are archived in a compressed TAR,
and with large files this demands considerable on-master resources, particularly CPU time.
There's not a hard stash size limit, but between 5-100 MB you should probably consider alternatives.
大体翻译下就是:ui
暂时将文件存储起来(具体存在哪,没看到管方解释),后需经过unstash方式调用this
可是呢:spa
stash会将文件打包成一个tar包来敦促,因此大文件时会耗CPU,并且stash有文件大小限制,尽可能在100M如下翻译
除了stash方法,还有一个archive的方法也能够存文件code
可是这两者区别是:blog
stash会在pipeline任务结束后将文件所有删除,而archive会一直保存文件,且在jenkins页面上显示ip
在实际使用过程当中,有一点须要注意的是:
stash只能放在最后,且只能一次,屡次是不执行的,以下面方式是错误的
stash includes: 'aa\\*', name: BUILD_NUMBER stash includes: 'bb\\*', name: bb
实际测试中发出,只会stash aa文件夹内容,后面的bb stash都没有执行