当前位置:网站首页>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
边栏推荐
- Circuit on-line simulation
- arcMap 发布切片服务
- Installation, use and problem summary of binlog2sql tool
- Summary of several relationships of UML class diagram
- Android Development: the client obtains the latest value in the database in real time and displays it on the interface
- Convert string to JSON
- Zero cost, zero foundation, build profitable film and television applet
- Golang timer
- SSDB foundation 2
- Common processing of point cloud dataset
猜你喜欢

Using oes texture + glsurfaceview + JNI to realize player picture processing based on OpenGL es

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

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

Class loading mechanism

JVM的类加载过程

Application of DCT transform

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

命令-sudo

优先使用组合而不使用继承

MySQL syntax collation (2)
随机推荐
Hot reload debugging
C1000k TCP connection upper limit test 1
SSDB foundation 2
[transfer] summary of new features of js-es6 (one picture)
NiO related Basics
openlayers 5.0 离散聚合点
Using 8266 as serial port debugging tool
Strange passion
Codeforces Round #783 (Div. 2) D题解
js获取本机ip地址
SSDB foundation 1
Common SQL commands
Data analysis learning directory
Web Security
浅谈c语言指针的强制转换
Reflection on the performance of some OpenGL operations in the past
RuntimeError: Providing a bool or integral fill value without setting the optional `dtype` or `out`
The most detailed network counting experiment in history (2) -- rip experiment of layer 3 switch
【玩转Lighthouse】腾讯云轻量服务器搭建全平台视频解析视频下载网站
Is it safe to open an account in Bohai futures.