尝试编写 subversion 提交后脚本将 PHP tu 导出到公共文件夹

发布于 2024-10-19 11:25:06 字数 515 浏览 6 评论 0原文

我正在尝试使用 subversion 和提交后脚本部署 PHP 应用程序。我一直在寻找如何编写提交后脚本,但我无法让它工作。

配置:我在我的服务器(OVH)上安装了一个 svn 文件夹,位于 homeX.XX/svn/test/

我的提交后脚本应该导出到 homeX.XX/dev/ >

使用时如何编写正确的路径

#!/bin/bash
mkdir dev
chmod 777 dev
svn export svn+ssh://[email protected]/homeX.XX/XXX/svn/test dev

我不知道在POST-COMMIT 脚本中 。我一直在寻找答案,但没有找到任何...

I am trying to deploy a PHP application using subversion and post-commit script. I've been looking for how to write post-commit script but i can't get it to work.

Configuration : I have a svn folder installed on my server (OVH) in homeX.XX/svn/test/

My post-commit script should EXPORT to homeX.XX/dev/

I don't know how to write the proper path when using

#!/bin/bash
mkdir dev
chmod 777 dev
svn export svn+ssh://[email protected]/homeX.XX/XXX/svn/test dev

in my POST-COMMIT script. I've been looking for answers but did not find any...

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

人海汹涌 2024-10-26 11:25:06

来自 SVN 文档(此处):

Subversion 存储库在空环境中执行钩子程序,即根本没有设置任何环境变量,甚至没有设置 $PATH。

我已经被这个问题困扰过好几次了。基本上,编写 SVN 提交挂钩的最简单方法(虽然不是很干净)是将您需要的所有文件和目录硬编码为绝对路径。

因此,在这种情况下,您的脚本将类似于:

#!/bin/bash

# SVN-related variables
svnuser=XXXXX
svnhost=www.xxxx.com
svnpath=/homeX.XX/XXX/svn/test

# Local paths
exportpath=/homeX.XX/dev

# Make export dir if it does not exist
if [ ! -e "$exportpath" ]
then
    mkdir $exportpath
fi

# These permissions are very lenient! Are you sure you want this?
chmod 777 $exportpath

# Do the SVN export
export svn+ssh://$svnuser@$svnhost$svnpath $exportpath

From the SVN documentation (here):

The Subversion repository executes hook programs with an empty environment—that is, no environment variables are set at all, not even $PATH.

I've been stung by this problem a few times. Basically the easiest way to write SVN commit hooks, although not very clean, is to hardcode all files and directories that you need as absolute paths.

So in this case, your script would look something like:

#!/bin/bash

# SVN-related variables
svnuser=XXXXX
svnhost=www.xxxx.com
svnpath=/homeX.XX/XXX/svn/test

# Local paths
exportpath=/homeX.XX/dev

# Make export dir if it does not exist
if [ ! -e "$exportpath" ]
then
    mkdir $exportpath
fi

# These permissions are very lenient! Are you sure you want this?
chmod 777 $exportpath

# Do the SVN export
export svn+ssh://$svnuser@$svnhost$svnpath $exportpath
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文