当前位置:网站首页>Jenkins - 访问 Jenkins 自定义参数变量,处理变量值中含有空格
Jenkins - 访问 Jenkins 自定义参数变量,处理变量值中含有空格
2022-06-28 00:15:00 【wumingxiaoyao】
引言
Jenkins job 中会自定义一些变量,这些变量将被不同的插件访问。工作中有遇到一个坑,就是变量值中含有空格时,当变量做为参数调用 Python 函数时,空格后面的内容会被截断,本文将解决这个问题。
内容提要:
- 定义变量
- Execute Python script 插件访问变量
- Execute shell 插件访问变量
定义变量
Jenkins job 中通过 Add Parameter 定义变量了一个 String 类型的变量 Project_Name, 默认值是含有空格的。
Execute Python script 插件访问变量
执行 Python 脚本,通过 os.getenv(‘Project_Name’) 访问变量,打印的值是 Project XXX
Execute shell 插件访问变量
执行 Shell 命令,可以通过 ${Project_Name} 或 %{Project_Name}% 访问变量
通过 echo 命令输出的变量值是正常的 Project XXX
但是做为参数调用 python 脚本,会有意想不到的结果。 传入 $ {Project_Name } 作为参数,变量值是 Project,空格后面的内容就被截断了。
为了能取到完整的变量值,需要加到 " ", " ${Project_Name} " 获取到的值就是完整的 Project XXX
边栏推荐
- Original | 2025 to achieve the "five ones" goal! The four products of Jiefang power are officially released
- Hi, you have a code review strategy to check!
- pytorch_ lightning. utilities. exceptions. MisconfigurationException: You requested GPUs: [1] But...
- Machine learning notes - time series as features
- Capacitor
- Adobe Premiere foundation - sound adjustment (volume correction, noise reduction, telephone tone, pitch shifter, parameter equalizer) (XVIII)
- 嵌入式必学,硬件资源接口详解——基于ARM AM335X开发板 (上)
- Numpy----np. Tile() function parsing
- 评价——秩和比综合评价
- 深入解析kubernetes controller-runtime
猜你喜欢
![pytorch_lightning.utilities.exceptions.MisconfigurationException: You requested GPUs: [1] But...](/img/b4/8921c3ca5cd5a547768489d4a79202.png)
pytorch_lightning.utilities.exceptions.MisconfigurationException: You requested GPUs: [1] But...

嵌入式必学,硬件资源接口详解——基于ARM AM335X开发板 (上)

数据库查询优化:主从读写分离及常见问题

【牛客讨论区】第四章:Redis

要搞清楚什么是同步,异步,串行,并行,并发,进程,线程,协程

Lmsoc: a socially sensitive pre training method

Solon 1.8.3 release, cloud native microservice development framework

Class initialization and callback usage

Differences between cesium polygon extrudedheight and height

Numpy----np.reshape()
随机推荐
fiddle如何使用代理
Cesium 多边形增加文字标签(polygon 加 label)多边形中心点偏移问题解决
Review of drug discovery-02-prediction of molecular properties
要搞清楚什么是同步,异步,串行,并行,并发,进程,线程,协程
类的初始化与回调的用法
零基础多图详解图神经网络
PV operation primitive
药物发现综述-03-分子设计与优化
Differences between cesium polygon extrudedheight and height
机器学习笔记 - 时间序列作为特征
[Yocto RM] 4 - Source Directory Structure
Capacitor
引用层reboot后的大体流程
TIA botu_ Concrete method of making analog input and output Global Library Based on SCL language
Solve storage problems? WMS warehouse management system solution
指南针股票开户是会有什么风险吗?指南针开户安全吗
To understand what is synchronous, asynchronous, serial, parallel, concurrent, process, thread, and coroutine
[Yocto RM]3 - Yocto Project Releases and the Stable Release Process
Appium自动化测试基础 — ADB常用命令(一)
OS模块与OS.path 模块的学习