Bash 使用exec插件从Maven 3执行脚本-被阻止

Bash 使用exec插件从Maven 3执行脚本-被阻止,bash,shell,maven,maven-3,maven-site-plugin,Bash,Shell,Maven,Maven 3,Maven Site Plugin,这就是我面临的情况:目前我有两个Maven项目,一个只做描述依赖项、存储库等的工作(父项目),另一个继承另一个的pom.xml的子项目。将来将创建更多模块,遵循与子模块相同的模型 我们决定将项目的站点(使用maven站点插件生成)部署到目前只能通过sftp访问的位置。我发现无法在中定义站点位置,因为我无法集成sftp协议(我尝试使用外部ssh) 因此,我创建了一个脚本,该脚本连接到远程计算机,并上载在站点部署阶段部署站点的本地文件夹的内容: echo "Uploading the site.."

这就是我面临的情况:目前我有两个Maven项目,一个只做描述依赖项、存储库等的工作(父项目),另一个继承另一个的pom.xml的子项目。将来将创建更多模块,遵循与子模块相同的模型

我们决定将项目的站点(使用maven站点插件生成)部署到目前只能通过sftp访问的位置。我发现无法在
中定义站点位置,因为我无法集成sftp协议(我尝试使用外部ssh)

因此,我创建了一个脚本,该脚本连接到远程计算机,并上载在站点部署阶段部署站点的本地文件夹的内容:

echo "Uploading the site.."
lftp -u ${username},${password} sftp://${host} <<EOF
mirror -R --delete-first $sitedir $remotedir
echo "Exiting from lftp.."
bye
EOF
echo "Terminating script execution.."
从孩子那里:

<build>
 <plugin>
  <groupId>org.codehaus.mojo</groupId>          
  <artifactId>exec-maven-plugin</artifactId>
  <executions>
   <execution>
    <id>sh</id>
    <phase>site-deploy</phase>          
    <goals>
     <goal>exec</goal>
    </goals>
    <configuration>
     <executable>sh</executable>
     <arguments>
      <argument>../parent/publish-site.sh</argument>
      <argument>${localsitedir}/child</argument>
      ...
     </arguments>
    </configuration>
   </execution>
  </executions>
 </plugin>
</build>

org.codehaus.mojo
execmaven插件
嘘
站点部署
执行官
嘘
../parent/publish-site.sh
${localsitedir}/child
...
我尝试了不同的方法来配置exec插件(不使用
pluginManagement
,继承插件的父级配置,只重写参数部分,等等),它在完成脚本时总是被阻止,不会结束执行


站点上传正确,但当然,我不想每次更新站点时都手动终止Maven构建执行(同时,计划将项目中的工件部署到Jenkins服务器,因此站点部署有望在那时起作用)。

我的答案基于很多猜测。。。我遇到了一个关于SSH命令不终止的类似问题,原因是:

也许“lftp”启动了一个不退出的进程,也许(可能)maven exec插件在stdout和stderr上循环以打印所有相关消息,然后退出。如果没有被所有的作家关闭,它就会停止


试着将“lftp”的输出重定向到/dev/null,以防万一。

我的答案是基于很多猜测。。。我遇到了一个关于SSH命令不终止的类似问题,原因是:

也许“lftp”启动了一个不退出的进程,也许(可能)maven exec插件在stdout和stderr上循环以打印所有相关消息,然后退出。如果没有被所有的作家关闭,它就会停止


请尝试将“lftp”的输出重定向到/dev/null,以防万一。

这可能听起来很愚蠢,但您是否尝试在publish-site.sh末尾添加exit 0语句?这可能听起来很愚蠢,但您是否尝试在publish-site.sh末尾添加exit 0语句?
<build>
 <plugin>
  <groupId>org.codehaus.mojo</groupId>          
  <artifactId>exec-maven-plugin</artifactId>
  <executions>
   <execution>
    <id>sh</id>
    <phase>site-deploy</phase>          
    <goals>
     <goal>exec</goal>
    </goals>
    <configuration>
     <executable>sh</executable>
     <arguments>
      <argument>../parent/publish-site.sh</argument>
      <argument>${localsitedir}/child</argument>
      ...
     </arguments>
    </configuration>
   </execution>
  </executions>
 </plugin>
</build>