【问题标题】:How can I make the Ant task "SSHExec" run a command and exit before it's completed?如何让 Ant 任务“SSHExec”在完成之前运行命令并退出?
【发布时间】:2014-05-01 17:32:31
【问题描述】:

我有一个 ant 构建脚本,它连接到远程服务器并使用 SSHExec 启动本地构建。此构建大约需要 1 分钟,完成后它会向我发送一封电子邮件,但我的 ant 任务:

<sshexec
   host="${deploy.host}"
   username="${deploy.username}"
   trust="true"
   keyfile="${user.home}/.ssh/id_rsa"
   command="~/updateGit.sh"/>

将等到脚本完成。我尝试像这样传递&amp;(我假设我必须在 build.xml 中转义它):

<sshexec
   host="${deploy.host}"
   username="${deploy.username}"
   trust="true"
   keyfile="${user.home}/.ssh/id_rsa"
   command="~/updateGit.sh &amp;"/>

但这似乎并没有什么不同。如果这个额外的细节对任何人有帮助,脚本会生成大量输出,而互联网连接缓慢可能会导致脚本花费更长的时间(因为它的输出正在被管道返回,这种方法的假设是我只关心完成后输出,所以如果我把它打包成一封电子邮件,我可以在构建开始时监控我的收件箱,基本上这是一个穷人的持续集成)

【问题讨论】:

    标签: ant


    【解决方案1】:

    使用来自this answer 的信息(和nohup 命令)我更新了我的任务如下:

    <sshexec
      host="${deploy.host}"
      username="${deploy.username}"
      trust="true"
      keyfile="${user.home}/.ssh/id_rsa"
      command="nohup ~/updateGit.sh &gt; /dev/null 2&gt; error.log &lt; /dev/null &amp;"/>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2020-12-18
      • 2013-03-22
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-01-18
      • 1970-01-01
      相关资源
      最近更新 更多