当前位置:网站首页>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
边栏推荐
- openlayers 5.0 离散聚合点
- Build intelligent garbage classification applet based on Zero
- Matlab 2019 installation of deep learning toolbox model for googlenet network
- Wechat applet part of the mobile phone Preview PDF did not respond
- PostgreSQL
- [play with lighthouse] Tencent cloud lightweight server builds a full platform video analysis video download website
- An idea of rendering pipeline based on FBO
- js上传文件时控制文件类型和大小
- [报告] Microsoft :Application of deep learning methods in speech enhancement
- UML类图几种关系的总结
猜你喜欢
Prefer composition to inheritance
深度学习——特征工程小总结
MySQL syntax collation (3)
Partage de la conception de l'alimentation électrique de commutation et illustration des compétences en conception de l'alimentation électrique
Some records used by VS2010
8266 obtain 18b20 temperature
[report] Microsoft: application of deep learning methods in speech enhancement
RuntimeError: Providing a bool or integral fill value without setting the optional `dtype` or `out`
ArcMap connecting ArcGIS Server
MySQL syntax collation (4)
随机推荐
优先使用组合而不使用继承
深度学习——特征工程小总结
ArcGIS JS API dojoconfig configuration
Machine learning catalog
Class loading process of JVM
binlog2sql 工具安装使用及问题汇总
Build intelligent garbage classification applet based on Zero
Codeworks round 783 (Div. 2) d problem solution
arcMap 发布切片服务
Problems caused by flutter initialroute and home
JVM的类加载过程
One stop service platform for high-level talents and development of comprehensive service platform system for talents
UML类图几种关系的总结
The platinum library cannot search the debug process records of some projection devices
An algorithm problem was encountered during the interview_ Find the mirrored word pairs in the dictionary
OpenHarmony开源开发者成长计划,寻找改变世界的开源新生力!
Transaction processing of SQL Server database
MySQL syntax collation (3)
Is it safe to open an account in Bohai futures.
On the forced conversion of C language pointer