简体   繁体   English

如果作业名称包含空格,Python-Jenkins将引发create_job

[英]Python-Jenkins raises on create_job if the job name contains spaces

I am developing some automation with Jenkins, and I'm trying to create jobs with a simple script. 我正在使用Jenkins开发一些自动化功能,并且尝试使用简单的脚本来创建作业。

python-jenkins==0.2.1

The very odd problem I'm facing, is that i get a very generic 我面临的一个非常奇怪的问题是,我得到了一个非常通用的

jenkins.JenkinsException: create[job name] failed

and when I check on Jenkins, the job is actually created, the configuration is ok, but the name stops at the very first space. 当我检查Jenkins时,实际上已经创建了作业,配置还可以,但是名称停在第一个空格。 If the job name doesn't contain any space, no error is raised. 如果作业名称不包含任何空格,则不会引发任何错误。

Any of you has experience with this? 你们中有人有经验吗? Or a suggestion on what it could be? 或对它的建议? Thanks! 谢谢!

Presumably the library is calling a command line tool and not properly escaping spaces in the arguments. 大概该库正在调用命令行工具,而没有正确地转义参数中的空格。 I'd report it as a bug. 我将其报告为错误。 In the meantime, assuming your job name doesn't have any apostrophes in it, you can try passing the name with apostrophes around it, eg 'name with spaces in' , or else use pipes.quote or shlex.quote on the name before passing it. 同时,假设您的工作名称中没有任何撇号,您可以尝试在名称周围加上撇号,例如'name with spaces in' ,或者在名称之前使用pipes.quoteshlex.quote通过它。

Since the job names translate to path names, you face the same issues with space in your jobnames, that you are facing with path names. 由于作业名称会转换为路径名称,因此您在作业名称中会遇到与路径名称相同的空格问题。 One of the easiest ways to fix this issue is to not allow spaces (and all other characters that will pose issues in filenames). 解决此问题的最简单方法之一是不允许使用空格(以及所有其他会在文件名中引起问题的字符)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM