简体   繁体   English

使用'。' 使用-D将参数传递给java二进制文件时不能很好地解析

[英]using '.' when passing parameters to java binary with -D does not parse well

I am using Jenkins CI to run java from execute shell build step : 我正在使用Jenkins CI从execute shell构建步骤运行java:

java -jar -Dadmin.hostname=$hostname -Dschema_name=$schema myapp.jar

I have noticed that although both parameters hostname and schema are defined well and has non empty values on runtime, Jenkins parses it the following way: 我注意到虽然两个参数hostnameschema都定义得很好并且在运行时具有非空值,但Jenkins通过以下方式解析它:

java -jar -Dadmin.hostname= -Dschema_name=MYDB myapp.jar

meaning admin.hostname value doesn't get parsed. 意思是admin.hostname值没有得到解析。

I have tracked the problem and noticed that when i dont use . 我已经跟踪了这个问题并发现当我不使用时. in the parameter name everything get parsed okay. 在参数名称中,一切都被解析好了。

I am wondering if this is a limitation of Java command line or a bug in Jenkins perhaps. 我想知道这是否是Java命令行的限制或Jenkins中的错误。 (I am using RHEL64) (我使用的是RHEL64)

Thanks 谢谢

EDIT: I think this is bug with Parametrized build jenkins plugin as using . 编辑:我认为这是使用参数化构建jenkins插件的错误. in other builds works fine. 在其他构建工作正常。

Perhaps the problem is that environment variables on UNIX are case sensitive 也许问题是UNIX上的环境变量区分大小写

$ echo $hostname

$ echo $HOSTNAME
myhostname

There shouldn't be any problem using . 使用时不应该有任何问题. because may built in properties uses them. 因为可能内置的属性使用它们。

BTW: Just because a property is set to blank doesn't mean its not set. 顺便说一句:仅仅因为属性设置为空白并不意味着它没有设置。

System.out.println("not.set=" + System.getProperty("not.set"));
System.out.println("admin.hostname='" + System.getProperty("admin.hostname")+"'");

when run with -Dadmin.hostname= prints 当使用-Dadmin.hostname= prints运行时

not.set=null
admin.hostname=''

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

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