当前位置:网站首页>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
边栏推荐
- [Yocto RM]9 - QA Error and Warning Messages
- [Yocto RM]1 - System Requirements
- 【ELT.ZIP】OpenHarmony啃论文俱乐部—数据密集型应用内存压缩
- 指南针股票开户是会有什么风险吗?指南针开户安全吗
- To understand what is synchronous, asynchronous, serial, parallel, concurrent, process, thread, and coroutine
- [Niuke discussion area] Chapter 4: redis
- 【永艺XY椅】试用体验
- 自监督学习与药物发现
- Appium自动化测试基础 — ADB常用命令(一)
- The practice of dual process guard and keeping alive in IM instant messaging development
猜你喜欢

Import the data table in MySQL into Excel

9. Openfeign service interface call

Jenkins - Pipeline 语法

【永艺XY椅】试用体验

Maimai hot post: Why are big factories keen on making wheels?

Xctf attack and defense world misc wage earner advanced zone

Adobe Premiere Basics - general operations for editing material files (offline files, replacing materials, material labels and grouping, material enabling, convenient adjustment of opacity, project pa

Numpy----np. reshape()

Cesium 抗锯齿(线,边框等)

将某数据库N多表名作为另外一张表中某一列得值(范围可以是别的数据库中得某张表)
随机推荐
Li Kou today's question -522 Longest special sequence
The interviewer asked: this point of JS
Cesium Click to obtain longitude and latitude (2D coordinates)
Drug interaction prediction based on learning size adaptive molecular substructure
Adobe Premiere foundation - sound adjustment (volume correction, noise reduction, telephone tone, pitch shifter, parameter equalizer) (XVIII)
Description du format geojson (détails du format)
Centos8 operation record command version Yum redis MySQL Nacos JDK
fiddle如何使用代理
外盘期货哪里可以开户?哪个平台出入金比较安全?
Numpy----np. Tile() function parsing
766. 托普利茨矩阵
frp实现内网穿透
Hi, you have a code review strategy to check!
零基礎多圖詳解圖神經網絡
Lmsoc: a socially sensitive pre training method
[Yocto RM]3 - Yocto Project Releases and the Stable Release Process
[Yongyi XY chair] trial experience
Shardingsphere-proxy-5.0.0 establish MySQL read / write separation connection (6)
[Niuke discussion area] Chapter 4: redis
【sylixos】i2c设备驱动创建和使用