【问题标题】:Ant properties with special characters带有特殊字符的 Ant 属性
【发布时间】:2014-06-07 16:34:03
【问题描述】:

我正在尝试将密码和用户名作为参数传递给我的 ant 文件 connectionTester.xml.. 我正在使用 -v 和 -d 选项运行 ant。 我所看到的房产变化让我非常恼火,无法找到解决方案。 密码包含 $ 字符,当后面跟一个构成 linux 命令的字符时,它会被替换,如下面的详细输出所示。

如何处理这种情况。密码被截断或替换为其他密码,最终构建失败。

[u@VM:h W]$ /opt/app/apache-ant-1.9.2/bin/ant -file connectionTester.xml -DdeployServer_user=xxxxxxx -DdeployServer.password=apr20$1 -v -d
Apache Ant(TM) version 1.9.2 compiled on July 8 2013
Buildfile: /home/xxxxxx/connectionTester.xml
Adding reference: ant.PropertyHelper
Detected Java version: 1.7 in: /usr/java/jdk1.7.0_25/jre
Detected OS: Linux
Adding reference: ant.ComponentHelper
Setting ro project property: deployServer_user -> xx49783
Setting ro project property: deployServer.password -> apr20-file
Setting ro project property: ant.file -> /home/xx49663/connectionTester.xml
Setting ro project property: ant.file.type -> file

【问题讨论】:

    标签: java linux ant build-process


    【解决方案1】:

    尝试在 ant 调用之前在命令行中设置密码并转义 $ 的含义(考虑到它在命令行中作为纯文本传递),就像在命令行中一样

    $myPass=apr20\$1
    

    然后用

    -DdeployServer.password=$myPass
    

    【讨论】:

    • 为了提问,我粘贴了 ant 命令。但这是根据 Jenkins 的参数化工作制定的。如何更改参数值以在 Jenkins 中添加转义序列?
    【解决方案2】:

    试着像过去一样

    -DdeployServer.password='apr20\$1'
    

    【讨论】:

      猜你喜欢
      • 2021-03-06
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2023-03-14
      • 2012-10-06
      • 2018-11-14
      • 2012-09-15
      相关资源
      最近更新 更多