2012-08-15 69 views
0

我想弄清楚如何使用脚本自动执行此过程。使用shell脚本来自动化git提交和ssh apache服务器部署?

我不知道我会用什么,或如何去做。我期待着指出正确的方向。

在混帐:

git commit -am "my commit" 
git pull origin my_branch 
git push origin my_branch 
git archive --format zip --output /c/git/(environment)_(date)_(commithash).zip my_branch 
scp (environment)_(date)_(hash).zip [email protected]:/var/www/html-(domain) 
password123 

在阿帕奇:(通常我腻子...)

root 
password123 
cd /var/www/html-(domain)/(environment) 
unzip ../(environment)_(date)_(commithash).zip 
n 
n 
A 
cd .. 
cp -pr (environment) (environment)_(date)_(commithash) 
exit 

为了解释怎么回事,我推着我的最新承诺, SCP到Apache服务器docroot,部署和使用提交散列进行备份。

+0

你不想要sh,你想要make。 – 2012-08-15 18:09:41

+0

看看[期望](http://www.nist.gov/el/msid/expect.cfm),它可以轻松地为您自动执行重复任务。 – twmb 2012-08-15 21:40:15

回答

1

您可以使用一个shell脚本,你打算 - 只需保存你想运行在一个文件中(每行一个),在顶部加入#!/bin/bash的命令,与chmod +x myscript.sh(该.sh文件扩展使其可执行不需要),然后用./myscript.sh运行它。

您可能会发现使用特别有助于部署的脚手架更容易。这些使用shell脚本的系统(我还没有尝试过)的外观好看的是deliver

+0

您可以创建与Windows等效的Powershell脚本。我找到了[使用Powershell部署]的示例(http://www.codeproject.com/Articles/16768/Deployment-made-simple-using-Powershell),但是您的里程可能会有所不同。 – supervacuo 2012-08-15 18:23:57

1

您正在迈向Continuous Integration的第一步。

我用Jenkins这是我设置的话:

  • 的git拉出身主
  • 运行单元测试
  • 部署代码
  • 运行数据库部署
  • 更新售票系统,成功/失败

有很多o f扩展和工具,以及任何语言,等等。