无法使用 ant exec 任务 运行 bash 脚本
Unable to run bash script with ant exec task
我正在尝试从 ant exec 任务执行 bash 脚本。
<target name="test" unless="${is.windows}">
<chmod file="./abc.sh" perm="a+x"/>
<exec dir="./" spawn="false" executable="bash" newenvironment="false">
<arg line="abc.sh ${some-argument}" />
</exec>
</target>
bash 脚本有 shebang #!/bin/bash。
当我 运行 目标时,它会在构建生产代码的 Jenkins 机器上为我提供以下输出。它在我本地的 CentOS 机器上运行良好。大多数行都是空的。在第 19 行,它有 {(左花括号)-
[exec] abc.sh: line 2:
[exec] : command not foundabc.sh: line 7:
[exec] : command not foundabc.sh: line 8:
[exec] : command not foundabc.sh: line 12:
[exec] : command not foundabc.sh: line 14:
[exec] : command not foundabc.sh: line 17:
[exec] : command not foundabc.sh: line 19: syntax error near unexpected token `{
[exec] 'abc.sh: line 19: `{
[exec] '
[exec] Result: 2
事实证明,dos 行结尾是问题所在。将 svn eol 属性 设置为 native 解决了这个问题。与在我们的 Jenkins 服务器上一样,每次构建都会检查代码,在 Windows 上编辑的 bash 脚本创建了与 centOS 不兼容的行尾。
我正在尝试从 ant exec 任务执行 bash 脚本。
<target name="test" unless="${is.windows}">
<chmod file="./abc.sh" perm="a+x"/>
<exec dir="./" spawn="false" executable="bash" newenvironment="false">
<arg line="abc.sh ${some-argument}" />
</exec>
</target>
bash 脚本有 shebang #!/bin/bash。
当我 运行 目标时,它会在构建生产代码的 Jenkins 机器上为我提供以下输出。它在我本地的 CentOS 机器上运行良好。大多数行都是空的。在第 19 行,它有 {(左花括号)-
[exec] abc.sh: line 2:
[exec] : command not foundabc.sh: line 7:
[exec] : command not foundabc.sh: line 8:
[exec] : command not foundabc.sh: line 12:
[exec] : command not foundabc.sh: line 14:
[exec] : command not foundabc.sh: line 17:
[exec] : command not foundabc.sh: line 19: syntax error near unexpected token `{
[exec] 'abc.sh: line 19: `{
[exec] '
[exec] Result: 2
事实证明,dos 行结尾是问题所在。将 svn eol 属性 设置为 native 解决了这个问题。与在我们的 Jenkins 服务器上一样,每次构建都会检查代码,在 Windows 上编辑的 bash 脚本创建了与 centOS 不兼容的行尾。