i try to solve the case where i need to make a PHP release on multiple remote Server nodes at the same time.
We got a Jenkins server wich does the following steps in his build (ant) script:
Git Checkout
PHP QA Tools Check (like PHPUnit, phpmd etc.)
Do some other tests
After everything is OK i want to deploy the sources to 3(later maybe more) remote Servers.
After everything is pushed to the Webnodes i want to execute a symlink change on all 3 nodes at the same time.
Sounds kind of impossible to me, but i hoped that i get a solution somewhere here, but i didn't found anything that helps.
So hopefully someone here got a good idea or some experience to share.
Cheers,
Dennis
You should look at this link because PHP deployments are a bit different from Java/.Net related deployments. However, if you feel that using Phing along with Jenkins OR using Phing independently is not what you want, and would like to simply have some plugin which copies your content to few remote servers, then you should try using Publish Over SSH plugin. After the steps in ant script mentioned above completes, you can add the task of deploying the sources to remote servers in Post-build Actions section. Once you've installed the plugin, you will find Send build artifacts over SSH option in the drop-down menu of Post-build Actions. Here you will find options to select multiple servers and you also have option to run command over those machines once the sources have been copied using Exec command that i have highlighted in the snapshot below. Also don't forget to check the Advanced... options and the help (?) section for each option.
Related
I'm sure there are answers for this all over stackoverflow but I was unable to find anything specific.
I have a PHP project which I am revisiting. Its running on a RHEL5 box. I have SVN on the same box.
Out of curiosity I recently added Jenkins to the machine and have the jenkins php template at...
http://jenkins-php.org/
There was a bit of playing around with the setup but I more or less have this all running and doing Continuous Inspection builds when something is committed to SVN.
What I want to do now is have Jenkins copy my updated files across to the server when the build completes.
I am running a simple LAMP setup and would ideally only like to copy across the files that have actually changed.
Should I just use ANT & sync? Currently the files reside on the same box as the server but this may change whereby I will need to sync these files across to multiple remote boxes.
Thanks
Check these - Copy Artifact Plugin and the job's env variables.
Now set 2 jobs - 1 on source machine and 1 on destination server (make it a slave). Use the plugin to copy required artifacts by using environment variables.
Do you have your project (not the jenkins but that with LAMP setup) under the SVN? If yes I'd recommend to create standalone job in Jenkins that will just do an svn up and you could tie it to jenkins job the way like - you running your main job, and if build is ok jenkins automatically runs job to update your project.
For copying to other servers take a look at Publish Over plugins
It's very easy to setup server and rules. The bad thing is that you can't setup copying only the new files for current build which means that the entire project is uploaded every build.
If your project is too big, another solution is to use rsync as post build action.
I'm just trying to find an easier way to deploy a site I'm working on. I'm working alone with a test a production server and right now deployment means copying a subset of the files and database data onto my computer and uploading it to the prod site. I'm sure there's a simple synchronization tool out there but so far I've had no luck in finding anything.
What I'd really like is an application I can run locally (on windows) or something I could install on my server for let me have a one-click deployment. Any suggestions?
Thanks!
godwin
Edit
I have decided for now to go with GoodSync and Toad. Thanks for the suggestions.
man scp
SCP(1) BSD General Commands Manual SCP(1)
NAME
scp - secure copy (remote file copy program)
SYNOPSIS
scp [-1246BCpqrv] [-c cipher] [-F ssh_config] [-i identity_file] [-l limit] [-o ssh_option] [-P port] [-S program] [[user#]host1:]file1
[...] [[user#]host2:]file2
DESCRIPTION
scp copies files between hosts on a network. It uses ssh(1) for data transfer, and uses the same authentication and provides the same
security as ssh(1). Unlike rcp(1), scp will ask for passwords or passphrases if they are needed for authentication.
Any file name may contain a host and user specification to indicate that the file is to be copied to/from that host. Copies between two
remote hosts are permitted.
When copying a source file to a target file which already exists, scp will replace the contents of the target file (keeping the inode).
If the target file does not yet exist, an empty file with the target file name is created, then filled with the source file contents. No
attempt is made at "near-atomic" transfer using temporary files.
The options are as follows:
-1 Forces scp to use protocol 1.
-2 Forces scp to use protocol 2.
...
I use GoodSync http://www.goodsync.com/ for this sort of thing. It's really good. Runs on windows, can sync between any combination of local files (S)FTP, windows, linux network shares etc.
Then create a scheduled task/cronjob to run an export of the database into the syncronised folder and have one do an import at the other end. Obviously this process is one way.
http://www.phing.info/docs/guide/stable/
PHing is an automated build system made for PHP. Works with GIT, SVN, PHPUnit, etc...
You basically set up XML files that give PHing instructions on what to do. Allows you to run test suites along with build creation, build multiple varied versions at a time, copy files as well as db, and a bunch of other cool features.
Also, it's open source and platform independent.
What are you using for source control? Some tools like Git and SVN have ready-made methods for this sort of thing. See here for a quick Git solution.
I would second the advice about Git/SVN, but would put in a strong plug for Git via GitHub. Use GitHub as your "central" Git repository. Your local Git repository will push to GitHub, and your production server will pull from GitHub.
There is some overhead to learning Git/GitHub, but really, in the situation you've described (a single engineer and two servers), Git isn't any more complicated then SVN (or CVS or anything else).
We use an FTP Synchronizer, which seems to work pretty well. I don't know offhand of any good free ones.
Example: http://www.ftpsynchronizer.com/
Depends on what type of server you are running, but you could run SVN (Subversion). There is a plugin for Eclipse, Aptana, and Zend Studio if you use that to develop.
Essentially you could have a development repository that sits on the server. You would pull your code down to your local environment and commit it back after changes. Then you can setup another repository that is your live data or production thats linked back to your Development repository.
When you want to update the live data, you just update it so if any trouble happens you can roll back that code without having to roll back your development code. Once you get good at all that you can start branching and tagging your projects.
I personally use both SVN and Git, but I prefer Git because it works so much better. Though if you are using Windows, the command line tools just aren't the same as linux.
I have been researching a bit to try and configure a good development and release process for a 20+ strength development team with multi project responsibilities.
I wanted to go with GIT as the versioning system since it is easy to use, setup, backup and what not. I tried to read through several guides of svn and i realized well i dont have the time to setup a complicated process. I was able to find git client support on both linux and windows and thus was happy with that.
Now to enable multi project authentication and access i started using gitosis on top of git and was able to get the functionality i needed.
Now i am looking to setup pre-commit specifically server hooks, to make sure my developers follows phpcs thoroughly and i dont want them to checkin if they dont. Now is where GIT is giving me problems. Does there exist a server side pre-commit hook detection for GIT ? I looked around but people are using SVN when this need arose. Later maybe i would like to configure similar hooks for both jabascript and css since we are using them extensively, and i found something similar to phpcs going by the name of Squiz. I hope to use that.
Also i am looking for setting up hudson to integrate with JIRA and GIT to setup both builds and iterations for each project. Are there are pitfalls to look for here or this setup with not work ? If this works could i be pointed to some document where i can see how it will work for me?
No there are no pre-commit hooks that reside on the server, since you never commit remotely, you always commit locally. However, you could have hooks on the server that runs when people try to push code to it.
Spotify uses hudson, jira and git in their development process and it seems to be a successful combination. If you like code reviews you can also attach Gerrit.
I was just able to get Apache ANT running on my computer. The ant -version commando outputs the version number , verifying that the installation went well.
I have read that ANT is well suited to handle deployment of web applications including PHP projects and have spent some time to get it working, but I just can't get my head around how to set it up to sync my files to my web server.
How can I make ANT sync folderA with folderB ?
Thanks
Last time I checked (long ago) there was no remote sync task in Ant (only local). You would have to write a shell script that calls rsync and execute this from Ant instead. There is a number of remote tasks though. And you could check out your code from your VCS instead of syncing it to the server.
On a sidenote, you might want to consider Phing over Ant. It's a port of Ant to PHP. It has a FileSync Task. You can also add your own Tasks (written in PHP) and is commonly used in Continuous Integration servers for PHP.
Also see What is your preferred Deployment Strategy for PHP and a couple others.
Read the manual: http://ant.apache.org/manual/index.html
Look at the <copy> task.
I was looking to do the same and just came across this article on how to deploy using ant, maybe it'll give you a different way of going about it: Deploying using Ant
I m setting up SVN on my local web development server and I'm wanting to create a post-commit hook that exports the repo to the production server (either via FTP, SSH, etc) when the commit message contains the word "deploy" or something similar. I know this has to be a common function for SVN but I can't seem to find anything that does just this. Maybe another set of eyes will lead me to the correct solution...
Thanks in advance!
One thing I have done (on projects specifically designed for this type of release) is to checkout the project into my production server, then do an svn update on it when the code is ready to be moved to production.
As others have suggested, I'm not a huge fan of this. I've written post-commit hooks that update third-party ticketing, etc. systems via their HTTP APIs, and I'm not thrilled at the time it takes to actually commit a revision that matches the criteria--I think I'd be less thrilled if I had to wait for it to upload actual binaries to another server, even if it were on the same subnet. We also currently check in our builds from the build server and just check them out on the deployment servers, which is easily automatable.
Check out the documentation on post-commit hooks, as well as some basic examples. A google search for "svn post-commit hook" pulls up lots of examples.