当前位置:网站首页>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
边栏推荐
- 学习 pickle
- Centos8 operation record command version Yum redis MySQL Nacos JDK
- Jenkins - 邮件通知 Email Notification 插件
- Numpy----np. reshape()
- 【嵌入式基础】串口通信
- General process after reference layer reboot
- Deep parsing of kubernetes controller runtime
- Maimai hot post: Why are big factories keen on making wheels?
- MapReduce elementary programming practice
- Where can I open an account for foreign exchange futures? Which platform is safer for cash in and out?
猜你喜欢

数据库的新选择 Amazon Aurora

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

Adobe Premiere基础-声音调整(音量矫正,降噪,电话音,音高换挡器,参数均衡器)(十八)

Data analysts too hot? Monthly income 3W? Tell you the true situation of this industry with data

Cesium 获取屏幕所在经纬度范围

Adding text labels to cesium polygons the problem of polygon center point offset is solved
![[embedded foundation] serial port communication](/img/b7/18fec20e2d5fa5f226c6f8bb1e93d2.png)
[embedded foundation] serial port communication

Solve storage problems? WMS warehouse management system solution

Evaluation - rank sum ratio comprehensive evaluation

Import the data table in MySQL into Excel
随机推荐
Numpy----np. meshgrid()
JS random number (random number decimal)
What are the risks of opening a compass stock account? Is it safe to open a compass account
药物发现综述-03-分子设计与优化
引用层reboot后的大体流程
style中的scoped属性和lang属性
Réseau neuronal pour la solution détaillée Multi - diagrammes de fondation zéro
fiddle如何使用代理
How to study efficiently
[embedded foundation] memory (cache, ram, ROM, flash)
[Niuke discussion area] Chapter 4: redis
Capacitor
How to optimize the "message" list of IM
Chapitre 4: redis
树莓派实现温控风扇智能降温
How to read a paper
Class initialization and callback usage
General process after reference layer reboot
Implementation of timed tasks in laravel framework
Web3 technology initial experience and related learning materials