我正在尝试从ant exec task执行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
答案 0 :(得分:0)
事实证明dos线结束是问题所在。将svn eol属性设置为native修复了该问题。与我们的Jenkins服务器一样,代码将针对每个构建进行检出,在Windows上编辑的bash脚本创建的行结尾与centOS不兼容。