当前位置:网站首页>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
边栏推荐
- 混合app的介绍
- 要搞清楚什么是同步,异步,串行,并行,并发,进程,线程,协程
- ionic4实现半星评分
- 766. toplitz matrix
- Appium automation test foundation ADB common commands (I)
- Voice network VQA: make the user's subjective experience of unknown video quality in real-time interaction known
- [Niuke discussion area] Chapter 4: redis
- 网络爬虫是什么
- Drug interaction prediction based on learning size adaptive molecular substructure
- Shardingsphere-proxy-5.0.0 establish MySQL read / write separation connection (6)
猜你喜欢

Cesium 点击绘制多边形(动态绘制多边形)

Raspberry pie realizes intelligent cooling by temperature control fan

Cesium Click to draw polygons (dynamically draw polygons)

机器学习笔记 - 时间序列作为特征

Adobe Premiere基础-常用的视频特效(边角定位,马赛克,模糊,锐化,手写工具,效果控件层级顺序)(十六)

自监督学习与药物发现

Adobe Premiere foundation - sound adjustment (volume correction, noise reduction, telephone tone, pitch shifter, parameter equalizer) (XVIII)

基于AM335X开发板 ARM Cortex-A8——Acontis EtherCAT主站开发案例

To understand what is synchronous, asynchronous, serial, parallel, concurrent, process, thread, and coroutine

Jenkins - Pipeline 概念及创建方式
随机推荐
Machine learning notes - time series as features
【牛客討論區】第四章:Redis
PV操作原语
Cesium obtains the latitude and longitude range of the screen
Appium自动化测试基础— 补充:App的包名(appPackage)和启动名(appActivity)
Database query optimization: master-slave read-write separation and common problems
[Yocto RM] 4 - Source Directory Structure
pytorch_lightning.utilities.exceptions.MisconfigurationException: You requested GPUs: [1] But...
ShardingSphere-proxy-5.0.0建立mysql读写分离的连接(六)
How to optimize the "message" list of IM
centos8-操作记录-命令版-yum-redis-mysql-nacos-jdk
[Yocto RM] 2 - Yocto Project Terms
Using redis bitmap to realize personnel online monitoring
指南针股票开户是会有什么风险吗?指南针开户安全吗
Cesium Click to draw polygons (dynamically draw polygons)
Solon 1.8.3 release, cloud native microservice development framework
Implementation of timed tasks in laravel framework
Lmsoc: a socially sensitive pre training method
[Yongyi XY chair] trial experience
What are the risks of opening a compass stock account? Is it safe to open a compass account