当前位置:网站首页>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
边栏推荐
- Customize the non slidable viewpage and how to use it
- [play with lighthouse] Tencent cloud lightweight server builds a full platform video analysis video download website
- Network protocol: SCTP flow control transmission protocol
- Thoughts on the optimization of examination papers in the examination system
- Web Security
- 高层次人才一站式服务平台开发 人才综合服务平台系统
- arcMap 发布切片服务
- ArcMap publishing slicing service
- Strange passion
- ArcMap connecting ArcGIS Server
猜你喜欢

ArcMap publishing slicing service

该买什么设备,Keysight 给你挑好了

redis优化系列(三)解决主从配置后的常见问题

Lottery applet, mother no longer have to worry about who does the dishes (assign tasks), so easy

5 minutes to achieve wechat cloud applet payment function (including source code)

JVM的类加载过程

Is meituan, a profit-making company with zero foundation, hungry? Coupon CPS applet (with source code)

RuntimeError: Providing a bool or integral fill value without setting the optional `dtype` or `out`

NiO related Basics
![[record] typeerror: this getOptions is not a function](/img/c9/0d92891b6beec3d6085bd3da516f00.png)
[record] typeerror: this getOptions is not a function
随机推荐
Quick start to static class variables
openlayers 5.0 热力图
Go recursively loops through folders
FTP、ssh远程访问及控制
Virtual machine performance monitoring and fault handling tools
SQL Server database in clause and exists clause conversion
SQL server requires to query the information of all employees with surname 'Wang'
Decompile and get the source code of any wechat applet - just read this (latest)
Application of DCT transform
The flyer realizes page Jump through routing routes
One stop service platform for high-level talents and development of comprehensive service platform system for talents
[报告] Microsoft :Application of deep learning methods in speech enhancement
Wechat video extraction and receiving file path
Some records used by VS2010
Hot reload debugging
5 minutes to achieve wechat cloud applet payment function (including source code)
浅谈c语言指针的强制转换
UML类图几种关系的总结
Regular expressions for judging positive integers
FTP, SSH Remote Access and control