当前位置:网站首页>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
边栏推荐
- JS 数组随机取值(随机数组取值)
- Evaluation - rank sum ratio comprehensive evaluation
- Chapitre 4: redis
- [Yocto RM]8 - OpenEmbedded Kickstart (.wks) Reference
- Cesium Click to obtain longitude and latitude (2D coordinates)
- 【永艺XY椅】试用体验
- Hi, you have a code review strategy to check!
- PV操作原语
- 基于AM335X开发板 ARM Cortex-A8——Acontis EtherCAT主站开发案例
- Cesium 点击获取经纬度(二维坐标)
猜你喜欢

Self supervised learning and drug discovery

Interviewer asked: Inheritance of JS

Database query optimization: master-slave read-write separation and common problems

Intranet penetration with FRP

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

【ELT.ZIP】OpenHarmony啃论文俱乐部—数据密集型应用内存压缩

Cesium Click to draw polygons (dynamically draw polygons)

Hi, you have a code review strategy to check!

Numpy----np. reshape()

How to understand query, key and value in transformer
随机推荐
Using redis bitmap to realize personnel online monitoring
Cesium 多边形(polygon)extrudedHeight 和 height 的区别
[Yocto RM]3 - Yocto Project Releases and the Stable Release Process
Interviewer asked: Inheritance of JS
The practice of dual process guard and keeping alive in IM instant messaging development
Prometeus 2.35.0 new features
[Yocto RM]1 - System Requirements
[embedded foundation] memory (cache, ram, ROM, flash)
Numpy----np. meshgrid()
TI AM3352/54/59 工业核心板硬件说明书
How fiddle uses agents
Intranet penetration with FRP
Adobe Premiere基础-声音调整(音量矫正,降噪,电话音,音高换挡器,参数均衡器)(十八)
I/o limit process and CPU limit process
Overview of drug discovery-01 overview of drug discovery
【嵌入式基础】串口通信
Cesium Click to obtain longitude and latitude (2D coordinates)
Adding text labels to cesium polygons the problem of polygon center point offset is solved
Cesium 点击获取经纬度(二维坐标)
利用redis bitmap实现人员在线情况监控