当前位置:网站首页>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
边栏推荐
- I/O限制进程与CPU限制进程
- 网络爬虫是什么
- Review of drug discovery-02-prediction of molecular properties
- Jenkins - Pipeline 概念及创建方式
- [Yocto RM]8 - OpenEmbedded Kickstart (.wks) Reference
- How to read a paper
- Prometeus 2.35.0 new features
- 【sylixos】NEW_1 型字符驱动示例
- Adobe Premiere基础-编辑素材文件常规操作(脱机文件,替换素材,素材标签和编组,素材启用,便捷调节不透明度,项目打包)(十七)
- The interviewer asked: this point of JS
猜你喜欢
MapReduce elementary programming practice
Appium automation test foundation ADB common commands (I)
Review of drug discovery-02-prediction of molecular properties
[Yongyi XY chair] trial experience
数据库的新选择 Amazon Aurora
Jenkins - 邮件通知 Email Notification 插件
766. toplitz matrix
Cesium 多边形(polygon)extrudedHeight 和 height 的区别
How to optimize the "message" list of IM
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
随机推荐
要搞清楚什么是同步,异步,串行,并行,并发,进程,线程,协程
[Yocto RM] 2 - Yocto Project Terms
What are the risks of opening a compass stock account? Is it safe to open a compass account
Machine learning notes - time series as features
机器学习笔记 - 时间序列作为特征
【牛客讨论区】第四章:Redis
How to optimize the "message" list of IM
树莓派实现温控风扇智能降温
MapReduce elementary programming practice
Chapitre 4: redis
Self supervised learning and drug discovery
fiddle如何使用代理
Implementation of timed tasks in laravel framework
Adobe Premiere基础-编辑素材文件常规操作(脱机文件,替换素材,素材标签和编组,素材启用,便捷调节不透明度,项目打包)(十七)
嵌入式必学,硬件资源接口详解——基于ARM AM335X开发板 (上)
Arrays. Aslist() pit
JS 数组随机取值(随机数组取值)
将某数据库N多表名作为另外一张表中某一列得值(范围可以是别的数据库中得某张表)
[Yocto RM]9 - QA Error and Warning Messages
Deep parsing of kubernetes controller runtime