简体   繁体   English

使用shell脚本自动执行git提交和ssh apache服务器部署?

[英]using shell script to automate git commits and ssh apache server deployments?

I'm trying to figure out how I go about automating this process using a script. 我试图弄清楚如何使用脚本自动执行此过程。

I don't know what I'd use, or how to go about it. 我不知道我会使用什么,或者如何去做。 I'm looking to get pointed in the right direction. 我希望能指出正确的方向。

In git : 在git中:

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 root@12.3.4.56:/var/www/html-(domain)
password123

In apache : ( usually i putty in... ) 在阿帕奇:(通常我腻子...)

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

To explain whats going on, I am pushing my latest commit, SCPing to apache server docroot, deploying, and making backup with commit hash. 为了解释最新进展,我正在推动我的最新提交,SCP到apache服务器docroot,部署和使用提交哈希进行备份。

You can either use a shell script as you plan to -- just save the commands you want to run (one per line) in a file, add #!/bin/bash at the top, make it executable with chmod +x myscript.sh (the .sh file extension is not required) and then run it with ./myscript.sh . 您可以按计划使用shell脚本 - 只需在文件中保存要运行的命令(每行一个),在顶部添加#!/bin/bash ,使用chmod +x myscript.sh使其可执行chmod +x myscript.sh (不需要.sh文件扩展名)然后使用./myscript.sh运行它。

You may find it easier to use scaffolding that specifically assists with deployment. 您可能会发现使用特别有助于部署的脚手架更容易。 A nice-looking one of these systems (that I have yet to try) that uses shell scripts is deliver . 一个好看的这些系统之一(我还没有尝试)使用shell脚本deliver

You are taking the first step toward Continuous Integration . 您迈出了持续集成的第一步。

I use Jenkins which I set up to do: 我使用我设置的Jenkins

  • git pull origin master git pull origin master
  • run unit tests 运行单元测试
  • deploy code 部署代码
  • run db deployments 运行数据库部署
  • update ticket system with success/fail 更新票证系统成功/失败

There are lots of extensions and tools as well, works with any language, etc. 还有很多扩展和工具,适用于任何语言等。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM