开发者

Hudson Shellscript for exporting Sourcecode from SVN repository into production folder

I have one dedicated server which has the whole Lamp-Stack, SVN and Hudson installed. I would like to create a freestyle Hudson job, that gets the latest sourcecode out of my SVN-repository and puts it into my /var/www/myWebApp Folder.

How does the shell script need to look like?

EDIT

When I just use

svn export myRepoURL myWebAppFolder

i get an erro, stating:

Started by user anonymous
Reverting http://myIpAdress/repos
Updating http://myIpAdress/repos
At revision 2
no change for http://myIpAdress/repos since the previous build
[workspace] $ /bin/sh -xe /tmp/hudson7864414135197533508.sh
+ svn export http://myIpAdress/repos/myRepo
/var/www/myWebApp
Authentication realm: <http://myIpAdress> Subversion Repository
Password for 'hudson': Authentication realm: <http://myIpAdress> Subversion Repository
Username: svn: PROPFIND request failed on '/repos/myRepo'
svn: PROPFIND of '/repos/myRepo': authorization failed (http://myIpAdress)
Finished: FA开发者_如何学运维ILURE


It should look something like below

svn export [your svn URL] /var/www/myWebApp

Do let me know if I am missing something here ?


I would also just run a copy. Make sure not to copy the .svn folders and other files that shouldn't be accessible from the outside world.

I also looked up the svn export command and it looks even better. If your job is setup to checkout from svn you can also run svn export ${WORKSPACE}/* /var/www/myWebApp. This will only copy files that are under source control. However, it will give you the option to change some configurations (that are important for the environment you are deploying too) before deploying it to your target.

Very important in any case, come up with a means to check if it was successful. So at least check the error code of all the commands that you run.


Write a script to copy (using the 'cp' command) all of the files from the job's workspace to whatever location you want. You should make use of the 'WORKSPACE' environment variable provided by Hudson, which provides you the path to the job's workspace. The script will likely be able to run in whatever shell you are using.


I think the previously mentioned svn export is the right solution, but if you're going to do a copy, I recommend something like rsync or tar over a bare cp. Both will allow you to exclude certain files or directories, refer to the --exclude command line option. (Googling for tar exclude svn will point you in the right direction.) Rsync's advantage is that it will only copy changes, so the deployment is much quicker when only a small number of files have changed.

Other things to consider:

  • You should have a plan for deleting files that are no longer part of the repository.
  • You should consider how you will manage your web app's configuration. I don't recommend checking in a deployment configuration to subversion, especially if other developers need to make changes to this configuration in order to test locally. It's too easy for an accidental configuration change in subversion to break your production system.
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜