当前位置:网站首页>Jenkins - 訪問 Jenkins 自定義參數變量,處理變量值中含有空格
Jenkins - 訪問 Jenkins 自定義參數變量,處理變量值中含有空格
2022-06-28 02:12: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
边栏推荐
- [embedded foundation] memory (cache, ram, ROM, flash)
- Appium自动化测试基础— 补充:App的包名(appPackage)和启动名(appActivity)
- JS array random value (random array value)
- JS 随机数(随机数 小数)
- Arrays. Aslist() pit
- [Yocto RM]1 - System Requirements
- ShardingSphere-proxy-5.0.0建立mysql读写分离的连接(六)
- mysql面试百题集
- Raspberry pie realizes intelligent cooling by temperature control fan
- PV操作原语
猜你喜欢

Adobe Premiere基础-常用的视频特效(裁剪,黑白,剪辑速度,镜像,镜头光晕)(十五)

How to optimize the "message" list of IM

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

Differences between cesium polygon extrudedheight and height

The research group of Xuyong and duanwenhui of Tsinghua University has developed an efficient and accurate first principles electronic structure deep learning method and program

Appium automation test foundation - Supplement: app package name and appactivity

【牛客討論區】第四章:Redis

Xctf attack and defense world misc wage earner advanced zone

Class initialization and callback usage

Lmsoc: a socially sensitive pre training method
随机推荐
PV operation primitive
【ELT.ZIP】OpenHarmony啃论文俱乐部—数据密集型应用内存压缩
Evaluation - rank sum ratio comprehensive evaluation
JS array random value (random array value)
Supervised, unsupervised and semi supervised learning
【嵌入式基础】串口通信
Take n multiple table names of a database as the values of a column in another table (the range can be a table in another database)
Capacitor
要搞清楚什么是同步,异步,串行,并行,并发,进程,线程,协程
style中的scoped属性和lang属性
Adobe Premiere foundation - sound adjustment (volume correction, noise reduction, telephone tone, pitch shifter, parameter equalizer) (XVIII)
Adding text labels to cesium polygons the problem of polygon center point offset is solved
geojson 格式說明(格式詳解)
[Yocto RM]9 - QA Error and Warning Messages
[Yocto RM] 2 - Yocto Project Terms
Cesium 点击绘制多边形(动态绘制多边形)
类的初始化与回调的用法
解决ionic4 使用hammerjs手势 press 事件,页面无法滚动问题
Jenkins - 邮件通知 Email Notification 插件
Review of drug discovery-03-molecular design and optimization