当前位置:网站首页>DevOps集成-Jenkins 服务的环境变量和构建工具 Tools
DevOps集成-Jenkins 服务的环境变量和构建工具 Tools
2022-04-23 19:23:00 【隔壁老瓦】
一、环境变量
环境变量可以被看作是pipeline与Jenkins交互的媒介。比如,可以在 pipeline 中通过 BUILD_NUMBER 变量知道构建任务的当前构建次数。环境变量可以分为Jenkins内置变量和自定义变量。
1.1、Jenkins 内置变量
在pipeline执行时,Jenkins通过一个名为 env 的全局变量,将Jenkins内置环境变量暴露出来。
默认env的属性可以直接在 pipeline 中引用;有三种引用方式:
- ${env.BUILD_NUMBER} 方式一,推荐使用
- $env.BUILD_NUMBER 方式二,
- ${BUILD_NUMBER} 方式三,不推荐使用
下面我们简单介绍几个在实际工作中经常用到的变量。
- BUILD_NUMBER:构建号,累加的数字。
- BRANCH_NAME:多分支pipeline项目支持。
- BUILD_URL:当前构建的页面URL。
- GIT_BRANCH:通过git拉取的源码构建的项目才会有此变量。
1.2、自定义 Pipeline 环境变量
当pipeline变得复杂时,我们就会有定义自己的环境变量的需求。声明式pipeline提供了environment 指令,方便自定义变量。
另外,environment 指令可以在pipeline中定义,代表变量作用域为整个 pipeline;也可以在 stage 中定义,代表变量只在该阶段有效。
如果在environment中定义的变量与env中的变量重名,那么被重名的变量的值会被覆盖掉。
1.3、自定义全局环境变量
有时候,我们需要定义一些全局的跨pipeline的自定义变量。<
版权声明
本文为[隔壁老瓦]所创,转载请带上原文链接,感谢
https://blog.csdn.net/wxb880114/article/details/124309081
边栏推荐
- Common processing of point cloud dataset
- c1000k TCP 连接上限测试
- js 计算时间差
- 数据分析学习目录
- SQL of contention for system time plus time in ocrale database
- SQL Server database in clause and exists clause conversion
- static类变量快速入门
- Intuitive understanding of the essence of two-dimensional rotation
- Strange passion
- Openlayers 5.0 thermal diagram
猜你喜欢

Partage de la conception de l'alimentation électrique de commutation et illustration des compétences en conception de l'alimentation électrique

网络协议之:sctp流控制传输协议

MySQL syntax collation (5) -- functions, stored procedures and triggers

SQL常用的命令

Oracle configuration st_ geometry

Openharmony open source developer growth plan, looking for new open source forces that change the world!

MySQL syntax collation (3)

FTP, SSH Remote Access and control

On the forced conversion of C language pointer

NiO related Basics
随机推荐
腾讯云GPU最佳实践-使用jupyter pycharm远程开发训练
PostgreSQL
Easy mock local deployment (you need to experience three times in a crowded time. Li Zao will do the same as me. Love is like a festival mock)
Translation of audio signal processing and coding: Preface
SSDB foundation 3
Pdf reference learning notes
Class loading mechanism
2021-2022-2 ACM集训队每周程序设计竞赛(8)题解
OpenHarmony开源开发者成长计划,寻找改变世界的开源新生力!
js获取本机ip地址
开关电源设计分享及电源设计技巧图解
UML类图几种关系的总结
開關電源設計分享及電源設計技巧圖解
Modify the font size of hint in editext
The difference between ordinary inner class and static inner class
Customize the non slidable viewpage and how to use it
命令-sudo
Strange passion
The usage of slice and the difference between slice and array
[play with lighthouse] Tencent cloud lightweight server builds a full platform video analysis video download website