jenkins pipeline之stash/unstash
Jenkins Pipeline stash
2023-09-27 14:26:52 时间
在使用jenkins时,经常会问到文件怎么存储?
正好jenkins有一个stash的功能,下面简单介绍下:
先看看官方是怎么解释的:
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.
大致翻译下就是:
暂时将文件存储起来(具体存在哪,没看到管方解释),后需通过unstash方式调用
但是呢:
stash会将文件打包成一个tar包来敦促,所以大文件时会耗CPU,而且stash有文件大小限制,尽量在100M以下
除了stash方法,还有一个archive的方法也可以存文件
但是这二者区别是:
stash会在pipeline任务结束后将文件全部删除,而archive会一直保存文件,且在jenkins页面上显示
在实际使用过程中,有一点需要注意的是:
stash只能放在最后,且只能一次,多次是不执行的,如下面方式是错误的
stash includes: 'aa\\*', name: BUILD_NUMBER stash includes: 'bb\\*', name: bb
实际测试中发出,只会stash aa文件夹内容,后面的bb stash都没有执行
相关文章
- 在使用java -jar命令启动jenkins时,如何指定http端口号
- 在Jenkins中集成Sonarqube
- Jenkins插件安装失败时这么做就搞定啦
- 可替代 Jenkins:Drone 进一步简化 CI/CD
- Jenkins学习笔记第八篇pipeline机制
- jenkins学习笔记第十一篇pipeline发送邮件
- Jenkins构建简单流水线
- 【持续集成和交付】Jenkins环境搭建:Jenkins介绍、下载安装
- kubernetes跑jenkins动态slave
- Jenkins系列之五——通过Publish over SSH插件实现远程部署
- Jenkins安装插件提速(Windows)终极解决办法
- jenkins接通gitee的webhook做自动部署 vue、react、java、springBoot
- jenkins pipeline 配置
- jenkins pipeline 配置
- 更新Docker中的Jenkins版本
- jenkins+gitlab钩子+shell脚本基于git的tag实现App增量更新
- 【Jenkins自动化部署】Windows节点Python服务自动化构建
- jenkins 用法示例
- jenkins pipeline
- 【持续集成】centos+jenkins+git+maven,-bash: git: command not found报错处理