Creating a Continuous Integration enviroment for Flex with Hudson ( 4 )

Categories: flex
Written By: sebi

One of our projects reached the level of complexity by both the term of prebase and developer-hours that we decided to go for a test ride with a CI ( Continuous Integration ) server.

Config Hudson for real projects

Before we start to configure Hudson, let’s prepare a Flex project. Since we want Hudson to automatically build our application straight from SVN, commit our project to a repository. This is a bit out of the scope of this article, but I made a few shot to make it more interesting :P From the Flex builder your can do it with a single right click on your project, and Choose Team / Share

Share Project from Flex Builder

Share Project from Flex Builder

After importing and committing your files by click through the wizards, the project is ready for Hudson. Visit your Hudson server in your browser, for me it’s http://192.168.1.59:8080/, you should see the following welcome screen:

Hudson Welcome Screen

Hudson Welcome Screen

Create a new project in Hudson choosing the Build a free-style software project option.

Creating new projects in Hudson

Creating new projects in Hudson

Tick the Subversion under the Source Code Management, and fill out the details. As soon as you type, Hudson tries to verify the information, and in my case - as there’s no anonymous access to the repository, pops up an error. Follow the enter credentials link, and provide the username and password on the next page. After you successfully gave them, you can navigate back to the project’s configuration page, and now the error message should have disappear.

Credential error in Hudson

Credential error in Hudson

Time to test the basic config. Click on the Build now on the left. After a short time a progress bar and a link appears in the Build History box below the menu.

Starting build

Starting build

You can check the process by clicking on the link, and on the Console Output on the following page.

Build log

Build log

In my log we can see how Hudson successfully out-checked the sample project from the Google Code repository. The next step is to use Ant as we had figured out before to actually build the application.
The simplest thing is create a build file in the Flex Builder, and commit it to the SVN, and leave Hudson to check out. So create a new file in your project’s root in FB, name it build.xml - I actually used to name it autobuild to know that this one is used by CI’s.

<?xml version="1.0" encoding="utf-8"?>
<project name="HudsonTest" basedir="." default="default">
	<property name="SOURCE_DIRECTORY" value="src" />
	<property name="OUTPUT_DIRECTORY" value="bin-debug" />
	<property name="FLEX_HOME" value="/home/hudson/flex_sdks/3.4" />
	<taskdef resource="flexTasks.tasks" classpath="${FLEX_HOME}/ant/lib/flexTasks.jar"/>
	<target name="default">
		<mxmlc file="${SOURCE_DIRECTORY}/HudsonTest.mxml" output="${OUTPUT_DIRECTORY}/HudsonTest.swc"  />
	</target>
</project>

Commit the file, and add a build step to the project inHudson by opening the Add build step menu, and selecting Invoke Ant item in the Configure menu of the Project. If you used the build.xml name for your build file, you don’t have to set anything else here, the default settings are good.

Adding Ant as a build step

Adding Ant as a build step

After saving it, and clicking on the Build Now if everything is fine, you can enjoy a successful build log:

The final result

The final result

So now we have a working build server, and a basic project we can build whenever we want. In the next few part I will show you how the automatize the builds, upload the result, receive warnings on breaking the build, enforcing code style, adding html wrapper, compiling libraries and complex projects, and building AIR applications. So be prepared.

Leave a Reply