Configuring a CI Server With GIT on Ubuntu (Amazon EC2)
Written by Simon Bailey
I would say that the majority of Flash Platform developers have now used source control.
As a developer are you testing locally, committing to source control and finally manually deploying your SWF’s to staging and production environments?
Do you work on applications as part of a team?
Do you use Continuous Integration (CI) and automated builds?
My answer was yes to all of the above except unfortunately the CI process. As you may well know from my blog and on twitter I have a keen interest with Project Sprouts and recently have also looked at Buildr, particulary Dominic Graefen’s AS3 port: Buildr-as3.
Together with Dominic (share my pain) Graefen (thnx man), I have been determined to setup a CI server using Jenkins on an Amazon EC2 instance which compiles SWFs and runs FlexUnit tests, for example on commit to git.
This was not a straight forward task…in fact it was a Grade A pain in the ar$e but eventually (it would appear) I managed to refine the process down to achieve the goal. Below are the steps that I have taken to set up an EC2 micro-instance with Git, Jenkins, RVM, Ruby, VNC, standalone debugger Flash Player, Buildr-as3 and compile/run FlexUnit tests using a Flex 4 based example! I have setup and torn down at least 6 instances to test and remove surplus instructions so hopefully it’s as lean as possible.
I am sure there could be further refinements made and on one of my test server setups I found I had some odd output which I need to work out why and where?
*(gflashplayer:1490): GLib-GObject-WARNING **: instance of invalid non-instantiatable type `(null)’
(gflashplayer:1490): GLib-GObject-CRITICAL *: g_signal_handlers_disconnect_matched: assertion `G_TYPE_CHECK_INSTANCE (instance)’ failed
But the tests run and all is happy. Micro-instances and rvm/project builds are not fast and I found have a tendency to hang on the first run/install so perseverance is required, but once running, all seems sweet with the world. Any further tips or guidance would be most welcomed! Oh and if you want to see an example of using CI for your Flex/Flash project just take a peek at this super sweet example.
EC2 Setup
Add SSH keys to EC2
1
|
|
Create EC2 instance from AMI (includes gitolite)
1
|
|
Ubuntu Requirements
Includes basics from setup requirements
1 2 3 4 5 |
|
Install necessary packages for ruby/rvm/buildr
1
|
|
Jenkins Setup
Install Jenkins as per jenkins installation
Ensure port 8080 is open
1 2 3 4 5 |
|
Configure Jenkins user
1 2 3 |
|
RUBY/RVM Setup - logged in as jenkins user
Install RVM
Huge props to this dudes article.
1 2 3 |
|
Configure .bashrc & .profile
1 2 |
|
Copy below source to .bashrc and reload
1
|
|
Copy below source to .profile and reload
1
|
|
Java Setup
Install correct JDK
1
|
|
Configure JAVA_HOME path
1 2 3 4 5 6 7 |
|
Reload .bashrc
1
|
|
Check path is correct
1
|
|
Reboot - not 100% necessary
1
|
|
Ruby Setup
Install Ruby 1.9.2
1
|
|
note Takes a while on an EC2 micro-instance (seriously can take ages > 30mins)
Set 1.9.2 as ruby default
1
|
|
Prevent ri & RDoc creation due to time - optional
1 2 |
|
Gems Setup
Install Bundler
1
|
|
Install buildr
1
|
|
Install buildr-as3
1
|
|
Flash Setup
Install Standalone debugger FlashPlayer
As root
1 2 3 4 5 6 7 8 9 10 11 |
|
VNC Setup
Install Vnc server
Instructions sourced here
1 2 3 |
|
Enter a password & take notice of the number after the colon (:)
1
|
|
Replace the number “1” with the number from above.
1 2 3 |
|
Enable for Vnc Jenkins
1 2 3 4 5 |
|
Install XVNC plugin in jenkins
1 2 3 |
|
Reboot
Project Setup
1
|
|
Create a new project
In Jenkins create a new free-style software project called SomeProject.
Enable Xvnc for project
1
|
|
Run a build
To generate a workspace you need to run a build first
Install unzip
1
|
|
Copy local workspace to remote
1 2 3 |
|
You may want to guarantee the integrity of the following zip before performing wget
1
|
|
Unzip workspace and cleanup
1 2 3 |
|
Run first build on command line - also takes a long time for first build
1 2 3 4 |
|
Configure project build
In Jenkins > Project > Configure > Add Build Step > Execute Shell
1 2 |
|
Post Build Actions > Publish JUnit test result report
1
|
|
And finally click Save at the bottom of the configuration page.
Build Project
Click Build Now
Note this build may take a couple of attempts
Further reading