在从一台服务器迁移到另一台服务器时取消部署构建



task:我想取消部署一个项目,因为我要将它从一台服务器移动到另一台服务器。

my deployment script:

    <target name="deploy" depends="backup">
    <dirname file="${ant.file}" property="project.dir"/>
    <echo>Stop Apache</echo>
    <sshexec host="${host.name}" username="${username}" password="${password}" command="sudo /etc/init.d/apache2 stop" />
    <echo>Clean deployment space</echo>
    <sshexec host="${host.name}" username="${username}" password="${password}" command="cd ${vhost.dir}; echo ${password} | sudo -S rm -r *"/>
    <echo>Install new app</echo>
    <scp file="${project.dir}/${project.name}.tgz" todir="${build.login}:${vhost.dir}"  password="${password}"></scp>       
    <sshexec host="${host.name}" username="${username}" password="${password}" command="cd ${vhost.dir}; echo ${password} | sudo -S tar xvzf ${project.name}.tgz" />
    <sshexec host="${host.name}" username="${username}" password="${password}" command="echo ${password} | sudo -S cp ${vhost.dir}/${project.conf}-test.conf ${vhost.conf.dir}" />
    <sshexec host="${host.name}" username="${username}" password="${password}" command="cd ${vhost.dir}; echo ${password} | sudo -S chown -R wwwrun:sdt *" />
    <sshexec host="${host.name}" username="${username}" password="${password}" command="cd ${vhost.dir}; echo ${password} | sudo -S chmod -R ug+rwx *" />
    <!--  added for Symfony 2 -->
    <sshexec host="${host.name}" username="${username}" password="${password}" command="cd ${vhost.dir}; echo ${password} | sudo -S rm -r app/cache/*" failonerror="false" />
    <sshexec host="${host.name}" username="${username}" password="${password}" command="cd ${vhost.dir}; php app/console assets:install web" failonerror="false" />
    <sshexec host="${host.name}" username="${username}" password="${password}" command="cd ${vhost.dir}; php app/console assetic:dump" failonerror="false" />
    <echo>Cleanup installation</echo>
    <sshexec host="${host.name}" username="${username}" password="${password}" command="cd ${vhost.dir}; echo ${password} | sudo -S rm ${project.name}.tgz ${project.conf}-test.conf" />
    <echo>Start Apache</echo>
    <sshexec host="${host.name}" username="${username}" password="${password}" command="sudo /etc/init.d/apache2 start" />
</target>

请告诉我,如果我想取消部署,我应该在脚本中写什么。我有一个基于symfony2的项目,构建工具是Ant。

谢谢! !这个代码作为一个独立的工作吗?

<property name="project.conf" value="ecweb" />
<set-property name="vhost.dir" if-property-isset="vhost.dir_ext" />
 <target name="undeploy">
 <sshexec host="${host.name}" username="${username}" password="${password}" command="sudo  /etc/init.d/apache2 stop-graceful" />
 <sshexec host="${host.name}" username="${username}" password="${password}" command="cd  ${vhost.dir}; echo ${password} | sudo -S rm -r *"/>
 <sshexec host="${host.name}" username="${username}" password="${password}" command=" cd /etc/apache2/vhosts.d/ sudo -S rm -r ${project.conf}-${BUILD_ENVIRONMENT}.conf"/>
 <sshexec host="${host.name}" username="${username}" password="${password}" command="sudo /etc/init.d/apache2 start" />
 </target>

部署脚本中的以下逻辑是否有效地取消了应用程序的部署?

<echo>Clean deployment space</echo>
<sshexec host="${host.name}" username="${username}" password="${password}" command="cd ${vhost.dir}; echo ${password} | sudo -S rm -r *"/>

这不是真正的ANT问题,因为您正在运行远程shell脚本。

相关内容

  • 没有找到相关文章

最新更新