简体   繁体   English

手工与shell脚本持续集成

[英]Handmade continuous integration with shell script

I did a temporary solution for a small continuous integration with shell script. 我做了一个临时解决方案,用于与shell脚本进行小的持续集成。 It updates from svn and then copies files to site's root directory. 它从svn更新,然后将文件复制到站点的根目录。 So it looks like this 所以看起来像这样

cd ...

update svn

cp -R ... ...

And then put it in crontab. 然后将其放在crontab中。 Well, it works fine for temp. 好吧,它适合临时工作。 solution, but it would want to make some improvement and to define somehow that svn was changed (new revision appeared) and only in this case to copy files (well, its connected with every-minut copying files makes server work slower). 解决方案,但它需要进行一些改进并以某种方式定义svn的更改(出现了新的修订版),并且仅在这种情况下才能复制文件(很好,它与每分钟复制的文件连接使服务器的运行速度变慢)。

But im a mean user of linux :( 但是我是linux的普通用户:(

So the question is: how to define, using bash script, that svn got new commits and only in this case to make an update and other stuff, like copying files. 所以问题是:如何使用bash脚本定义svn是否具有新提交,并且仅在这种情况下才能进行更新和其他操作,例如复制文件。

You can do 'svn info' in the directory (and use awk|grep|your favorite tool) to extract the revision number of what you've checked out. 您可以在目录中执行“ svn info”(并使用awk | grep |您最喜欢的工具)以提取已检出内容的修订号。 Do the same to the location you copy to. 对要复制到的位置执行相同操作。 If the revision number in the checkout directory is higher than the one in the destination directory, then do the copy. 如果检出目录中的修订号高于目标目录中的修订号,则进行复制。

That's assuming that you copy everything including the .svn directories. 假设您复制了所有内容,包括.svn目录。

If you exclude them, then you should 'svn info' before you update, and again after, and compare the two revisions. 如果排除它们,则应该在更新之前“ svn info”,然后在更新和比较这两个修订版本时再次输入。

Stop. 停止。

Why in the world would you do this? 您为什么要这么做?

With eighty totally free, super easy to install, CI tools out there, why in the world would you start hacking your own together with shell scripts and cron? 有了80种完全免费,易于安装的CI工具,为什么在世界范围内会开始使用shell脚本和cron来黑客入侵自己的CI工具?

Unless you're looking to work on your scripting / cron skills and want to use building your own CI as an fun little scenario to play through, you're just wasting your time here. 除非您希望学习脚本/ cron技能,并且不想将构建自己的CI作为有趣的小场景来进行学习,否则您只是在浪费时间。

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

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