Stanislav Zorjan - Stasha - Full Stack Software Engineer and Game Development Hobbyist - Prague


In this post I will show you how to set up auto deployment in 5 minutes using Jenkins.

Jenkins is CI (continuous integration) server, which beside compiling and running tests, can do maaaany other things, and one of them is Auto Deployment.

Jenkins is also open source (MIT license), can run on many different platforms, is extensible and it's user interface is really clean and impressive.

Now, because Jenkins can do really lot of things (in combination with ANT or Maven it really becomes super extra luxury)
I will show you only basic setup for auto deployment to FTP server and point you in direction where you can learn more.
(Jenkins can be configured to fulfill almost any Auto Deploy scenario) 

First of all, you have to download Jenkins: http://jenkins-ci.org/
Jenkins can be downloaded as standalone package, or as java web archive "war" for running on application server.
If you don't have application server installed, download standard installer for your OS, unpack it and run.

After successful installation, if your browser is not automatically opened with Jenkins main page, open browser and go to address: http://localhost:8080/

You should see Jenkins main page.

Click on link "Manage Jenkins" and then "Manage Plugins"

Click on tab "Available", find plugin "FTP publisher plugin" check it, scroll to the bottom of the page and click button "Install"

After plugin installs, return back to Jenkins main page and click again "Manage Jenkins" and then "Configure System"

Scroll down to the "FTP" click on "Add" button and enter required parameters. If you don't know what parameters to add, use "?" button at the end of each text field.
(Here you are adding servers where files are going to be deployed, so if you have more servers, just repeat this step)
When you are done with adding servers click "Save" button at the bottom of the page.

Now click on "New Job" link.

Add name to the job, for example "Auto Deployment Test" select "Build a free-style software project" radio button and press "OK" button.

Locate section "Source Code Management", select "Subversion" and fill "Repository URL" (svn url to your source code).

Locate section "Build Triggers", select "Poll SCM" and insert "* * * * *" . This 5 stars means that Jenkins will pull changes from svn every minute, build it and deploy to FTP.
!!! NOTE !!! This is just a basic example. You should setup "post-commit" hook on svn to notify Jenkins every time code was committed. 
Here is wiki on how to setup "post-commit" hook to trigger Jenkins: https://wiki.jenkins-ci.org/display/JENKINS/Subversion+Plugin 

Locate checkbox "Send build artifacts over FTP" and check it.
From a drop down list, select FTP server you have added few steps before, and add directory, directories, or file paths to "Transfer Set / Source Files" text field.
(Use "?" at the end of the text field to learn more)

Click on the "Save" button, and you are done :) .

 

You have successfully set up Auto Deployment  to deploy files to FTP server every minute :) .