在使用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都沒有執行