Wednesday, November 24, 2010

Spring into Mobile Application Development

Spring into Mobile Application Development

Posted on November 19th, 2010 by Keith Donald in Spring.

Keith Donald

At SpringOne2gx we announced exciting new initiatives in the areas of social media and mobile application development. A few weeks ago, Craig Walls released Spring Social. Today, Roy Clarkson released Spring Mobile and Spring Android. In this post, I'd like to highlight these projects and share how Spring aims to simplify mobile application development.

Choices in Mobile Application Development

If you attended SpringOne2gx this year, you've seen Greenhouse, an app we built for our community that also serves as a reference and driver for Spring technology. Craig showed you some of the social elements of Greenhouse, such as the ability to connect your account with Twitter and Facebook. There are also a number of mobile elements. Specifically, Greenhouse doubles as a mobile web app, and sports native Greenhouse for iPhone and Android clients.

Like many organizations today, we had to answer the basic question of "what mobile platforms to target?" In the end, we chose to invest in a native experience for iPhone and Android users, while also developing a cross-platform mobile web app. Our decision to go native was driven by the fact the app is consumer-oriented, and a large number of prospective consumers (application developers) own iPhone and Android devices. At the same time, the mobile web app aims to provide a good baseline experience that works cross-platform, something that's possible today with the rise of WebKit and HTML 5.

From our development work, grew Spring Framework contributions: first, a Spring Mobile project that provides extensions to Spring MVC for developing mobile web apps; and second, a Spring Android project that supports the development of native Android clients that communicate with Spring-based back-ends. I'll take you through each of these projects in turn.

Spring Mobile

The first problem we tackled was designing a web app that was pleasant for mobile visitors to use. While a smartphone may have a capable web browser, it still has a small screen and that needs to be accounted for. There are essentially two approaches to dealing with this problem:

  1. Detect the device that originated the web request and serve a separate site to mobile devices.
  2. Serve a single site, but progressively enhance it for desktop users by using CSS 3 media queries and JavaScript.

You can find examples of both techniques in the wild today; for example, the conference site Lanyrd enhances through client-side detection, while SpeakerRate uses server-side detection that redirects mobile visitors to a separate site (see for yourself by installing the Firefox User Agent Switcher and setting your user agent to iPhone).

In Greenhouse, we started with server-side detection. Specifically, we aimed to apply a different page layout if the device was a mobile device. Out of this grew a general purpose "Device Resolver Abstraction", which is the defining feature of Spring Mobile 1.0.0.M1. Some highlights of this feature include:

  1. A HandlerInterceptor that uses a DeviceResolver to detect the Device that originated the current HttpServletRequest.
  2. The ability to inject the detected Device into @Controller methods and view templates to vary logic by device type.

Below are some usage examples from the Greenhouse codebase. First, have a look at the interceptor definition from /WEB-INF/spring/appServlet/servlet-context.xml:

1<interceptors>
2 <!-- On pre-handle, detect the device that originated the web request -->
3 <beans:bean class="org.springframework.mobile.device.mvc.DeviceResolvingHandlerInterceptor" />
4</interceptors>

Now, a JSP template that conditionally renders some content if the device is not a mobile device:

1Please try again<c:if test="${!currentDevice.mobile}"> or <a href="<c:url value="/signup" />">sign up</a></c:if>.

Finally, a Tiles-based page layout that changes if the device is a mobile device:

1<definition name="page" templateExpression="/WEB-INF/layouts/${currentDevice.mobile ? 'mobile/' : 'standard/'}page.jsp" />

In addition to these features, Spring Mobile 1.0.0.M1 ships:

  1. A HandlerInterceptor that redirects mobile visitors to another URL. This is useful if your mobile site truly is a separate application. Consider Flickr, for example, which will redirect you to m.flickr.com if you access www.flickr.com from your phone.
  2. A DeviceResolver implementation that delegates to WURFL for device detection. WURFL provides a large database of devices and their capabilities. It is useful when you need to know more about the Device that originated the request, such as its specific screen size, manufacturer, model, preferred markup, or other capabilities.

Recently, we have also begun exploring the use of CSS 3 media queries with JavaScript to perform client-side detection. This approach has the advantage of not requiring special server-side handling unless you aim to vary the semantic content you send to the device, and not just optimize the style. Not all browsers support media queries, so they may not be an option for you, but if you're targeting smartphones with WebKit-based browsers you should be fine. In general, the approach of first designing your app for mobile, then progressively enhancing it for desktop feels quite elegant to me.

Spring Android

For the Android client, a different set of challenges emerged. We needed to exchange data with the server over HTTPS via REST, and since that data is user-specific we require the user to sign in. Rather than use Basic Auth, where we would need to store username and password credentials on the device itself, we opted for OAuth.

OAuth is an emerging standard that provides a token-based authorization scheme. Essentially, a username and password is traded for an access token, and the access token is used to make requests for protected resources. This means you only need to store the access token with the device for "remember me" functionality. Furthermore, we chose to implement the sign in process whereby the client takes you to the server's web site for connection authorization. In this way, the client never sees your username and passsword, which is important if you allow third-party clients to be developed against your API (which we also want to encourage). Finally, in the event a user's phone is stolen or otherwise compromised, an access token can be invalidated without the risk of username and password compromise.

Out of this work, came the desire to get specific modules of the Spring Framework working in an Android environment. Specifically, we aimed to use RestTemplate for the REST API calls, and Spring Security for the OAuth client.

I'm pleased announce that the first milestone of Spring Android ships an "Android-ready" RestTemplate. We're using it in Greenhouse, and we encourage you to use it as the REST client in your own Android applications. Check out the example usage below:

1RestTemplate restTemplate = new RestTemplate(new CommonsClientHttpRequestFactory());
2Event event = restTemplate.getForObject("https://myapp.com/event/{name}", Event.class, "springone2gx");

In future milestones, you can expect more of the Spring Framework to be supported in an Android environment, such as the Spring Security OAuth client.

Getting Started

The best way to get started is to see it live by walking through the Greenhouse app in your own local development environment. As a reference, Greenhouse uses the Spring Mobile and Spring Android projects, as well as Spring MVC, Security, Social, and Integration. The project page provides a guide that shows you how to get the web app, iPhone client, and Android client all running in your local environment in minutes.

If you have questions about features, roadmap, or just want to have a discussion with the development team, please do visit our community forums. We value your feedback.

Summary

I'm very excited about all the new initiatives we've got going, and especially what we're doing in the social and mobile space. The first milestones of these projects are just the beginning. I encourage you to get involved in the projects that are useful to you and help us make them the best they can possibly be.

via blog.springsource.com

Need to check this out for some old Spring stuff I have worked on :)

Tuesday, November 16, 2010

NFC. What does it all mean?

NFC: Near Field Communications: a short-range high frequency wireless communication technology which enables the exchange of data between devices over about a 10 centimeter (around 4 inches) distance (via Wikipedia).

Well that's great, but what does it mean, especially when mentioned in conjunction with Gingerbread?

As you may (or may not) have heard this week at the Web2.0 Summit Eric Schmidt talk about Android 2.3 and its support for NFC. This could indeed lead the way for mobile payments on devices. NFC will allow for the transmission of credit card data over a defined radio frequency (13.56 MHz).

This isn't new, Japanese handsets (Keitai) have had this type of technology for a while (I want to say up to 10 years, but I can't back that up right now). Go google Osaifu-Keitai/keitai credit.

However this *is* all exciting news. There is potential for integrating it with conferences, museums, travel, healthcare, payment systems, and countless other things. Lets not forget though, some of these things already exist already:

  • Exxon SpeedPass
  • Debit cards with Visa PayWave.

Now we have another new way to gain information about our surroundings. #mobilefirst anyone?

Some interesting articles to peruse at your leisure.

RFID in Museums - Another Growing Market

Who Will Win the Mobile Payments Battle: Gadgets, NFC or Apps?

Intuit Squares Off In Mobile Credit, With A Little Help From Apple

Future Credit Cards: Electronic and RFID?

Web 2.0 Summit 2010: Eric Schmidt, "A Conversation with Eric Schmidt"

Thursday, November 11, 2010

Configuring LogBack in Roo

 Gordon Dickens, one of our trainers and architects, recently posted this on his Technophile Blog, on Roo. 


LogBack is the more versatile logging strategy created by the same person that created log4j. Use the following steps to configure your Roo 1.1 project to use LogBack.
See Also: Reasons to Switch to LogBack

1. Create a logback.xml file in src/main/resources

 Cont. here for the remainder of the post



Wednesday, November 10, 2010

Post Presentation Thoughts from our Mobile Seminar

Kevin Griffin was one of the presenters at our first Mobile Seminar Breakfast. Below is a recap of his thoughts after he finished his presentation.


Yesterday I presented at the first in a series of events for Chariot Solutions, the topic was 'Mobile Design Concepts'.

My goal was to try present things that I had learned/seen/been shown/done over the last couple of years, and try to get the audience out of the 'desktop browser' mind set when developing for mobile.

I drew from a lot of people that I have seen/meet including Luke Wroblewski (@LukeW), Josh Clark/Tapworthy (@globalmoxie), Mike Lee (@bmf) William Van Hecke (@fetjuel) and Brian Fling's book 'Mobile Design and Development' which I still think is the first book anyone planning on a mobile project should read. I was probably influenced by many more folks than that, but they are the obvious ones to me at the time of writing.

Cont. reading..

Monday, November 8, 2010

Grails Validation Constraints Quick Ref

This is an excerpt from a blog post by Gordon Dickens, Chariot Architect and Trainer (via Technophile Blog)

After several iterations of Grails, we have to go to 17 (seventeen) pages to see all the validation constraints? I wanted to see them on one page.

Grails 1.3.5 – Validation Constraints

blank – To validate that a String value is not blank

login(blank:false)
creditCard – To validate that a String value is a valid credit card number

cardNumber(creditCard:true)
email – To validate that a String value is a valid email address.


Click here for the rest of the article

Monday, October 4, 2010

Monthly Mobile Musings from September

Firstly I should apologize for being a few days late, September was a busy month!

I had the privilege and pleasure of joining a top notch panel discussion at 'Mobile Monday Mid-Atlantic' talking about mobile strategy. For anyone in the Philadelphia area interested/participating in mobile development, Mobile Monday is a must attend event, they have some great topics coming soon and we had a great attendance for the panel discussion again. My thanks again to MOMO-MA for the opportunity to speak and to the audience for the great questions which drove our discussions. I posted my morning after thoughts on my blog.

So back to the mobile news, September saw an interesting trend in rumors regarding new Android Markets, both Verizon and Amazon(!?) were floated as potentially offering alternatives, perhaps fueling the fragmentation. Legit news about Android Market expansion has them now featuring submissions from 20 new countries and taking paid markets up to 32 countries.

In a month where I got excited (yet again) over a new handset, the Nokia N8 supposedly launching next month (running Symbian 3) coupled with the Nokia and AT&T developer competition got us thinking finally Nokia would get the respect they deserve here in the US. Then Samsung spoiled it all by announcing it's plans to drop support at the years end, presumably to big up some WP7 love.

Speaking of WP7 love, I attended a Windows Phone 7 Fire-starter event here in Philly this month. My thoughts on that can be found on my blog. They are also having a launch event this month (October 11th) which engadget will be live at, check the details here.

Time for some Chariot house keeping, we have been hard at work getting ready for ETE 2011 (oh yes, already) and we have some *outstanding* mobile speakers already which will be announced soon, along with the rest of the line up. We are starting a mobile seminar series here in Philadelphia, starting on November 9th featuring a variety of talks and discussions, aimed at helping business identify their mobile needs and how to fulfill them.


Thursday, September 16, 2010

Setting up TeamCity CI w/ Cucumber, Flex, FunFX, and Firefox in a Headless Environment: Part Two

Recently I had the “opportunity” (read: challenge) to setup a continuous integration build for a project with a Flex frontend and a Ruby/Rails backend. The project had been converted from Java-Hibernate-Tomcat to Ruby on Rails. Cucumber was introduced for GUI testing using the FunFX adapter. It was my first experience with Cucumber, so the combination of Cucumber, FunFX, Flex, and Firefox was a little daunting at first. But we got through it and actually, it turned out to be quite an effective tool in our testing suite.

But the fun really started when I was tasked with building the TeamCity CI server for our project. And after it was all over, I felt I needed to document the trip so others might benefit from it, if not just for posterity. This is the second part of the two-part series on that journey.

Continuing…

In the first part we installed the open source software we are using: Java, Ruby, Rails, and all the required Ruby Gems, as well as the Flex 4.1.0 SDK, Firefox, FlashPlayer, and the Git client. The FunFX adapter for Cucumber uses JSSH to communicate with Firefox, so we configured and built Firefox with JSSH to run in a headless environment. We installed the latest Flex 4.1.0 SDK and the FlashPlayer 10.1 plugin for Firefox.

So what we have left is the installation and configuration of TeamCity itself as well as the setup of the build process for our Cucumber, Flex, and FunFX sample project.

So let’s get started.

Install TeamCity

Download the latest version of the Professional TeamCity software from the TeamCity web site for the appropriate platform. The Professional version is free but is limited in number of projects, build configurations, and users. We will only define one project and are well within the limit for build configurations.

We will be executing the installation instructions detailed on the TeamCity web site to install TeamCity bundled with the Tomcat servlet container on a Linux platform. They are relatively simple and are documented here. If you wish to install TeamCity to an existing Tomcat servlet container or on a different platform, please refer to the instructions for your specific environment.

We will be using the default admin user that we’ll define during installation. We will also be using HSQLDB and the default build agent. Most of the defaults will suffice for our installation.

Copy the TeamCity tar.gz file to the TeamCity server. SSH into the TeamCity server as yourself. Copy the TeamCity tar.gz file from /home/teamcity to /usr/local, unpackage the tar.gz file, and create a symlink to the TeamCity install directory. You will also need to change the owner of the TeamCity install directory to the 'teamcity' user.

$ cd /usr/local
$ sudo cp /home/teamcity/TeamCity-5.1.3.tar.gz .
$ sudo tar -xzvf TeamCity-5.1.3.tar.gz
$ sudo ln -s TeamCity teamcity
$ sudo chown -hR teamcity TeamCity

Logout as yourself and SSH into the TeamCity server as the ‘teamcity’ user. We will run the TeamCity CI server under this ‘teamcity’ user.

Since there is no physical display device attached to the TeamCity server, we need to indicate to TeamCity it will be running in headless mode. This is done by setting TeamCity’s java.awt.headless Java options property to true. You can either create a setenv.sh file in the bin directory or add the statement to the catalina.sh file. If you are installing TeamCity to execute in an existing Tomcat servlet container, add the statement to the catalina.sh file in its Tomcat installation’s bin directory.

$ cd /usr/local/teamcity/bin
$ echo 'JAVA_OPTS="$JAVA_OPTS -Djava.awt.headless=true"' > setenv.sh
$ chmod +x setenv.sh

You should also set the TEAMCITY_SERVER_MEM_OPTS and TEAMCITY_AGENT_MEM_OPTS environment variables as described in the instructions for the TeamCity startup options. Although these values may vary according to your build requirements, we set our values as follows:

TEAMCITY_SERVER_MEM_OPTS -Xms512m -Xmx1024m -XX:MaxPermSize=1024m
TEAMCITY_AGENT_MEM_OPTS -Xms512m -Xmx1024m -XX:MaxPermSize=1024m

Start the server with the following command:

$ sh /usr/local/teamcity/bin/runAll.sh start

Then bring up the TeamCity application in a local browser (http://localhost:8111). When the application is initialized for the first time, you are presented with the licensing and conditions of use page. After agreeing to the license, you are prompted to create an administrator account. Fill in the fields as appropriate and create the account. If you log out of TeamCity, use the credentials created here to log back in.

Create a CI Project

After creating the administrator account, you are presented with the Projects page. Select the Create Project link. Enter the appropriate values in the respective fields of the resulting screen:

Name: FC Converter
Description: Fahrenheit to Celsius Conversion project

Press the Create button.

Next we will associate the project with a version control system. Select the VCS Roots tab and then the +Create VCS root link.

Enter an appropriate VCS rootname and select the type of VCS from the dropdown.

The remainder of the screen is refreshed with the fields for the respective VCS. We are illustrating Git here. Enter / select as appropriate for the respective fields:

VCS rootname: fc_converter-root
Type of VCS: Git (Jetbrains)
Fetch URL: git://github.com/landerson/FC-Converter.git
Push URL: (leave blank to use Fetch URL)
Branch name: master
Clone repository to: checkout
User Name Style: Userid(jsmith)
Submodules: Checkout
Authentication Method: Anonymous
User name: (leave blank)
Path to git: /usr/bin/git(or as appropriate)
Clean Policy: (as appropriate)
Checking Interval: (as appropriate)

Press the Test Connection button to test the SSH handshake with github. The test should succeed. The test must succeed in order for the TeamCity build configuration to work properly. After the test succeeds, press the Save button.

Select the General tab to return to the main project page. It is from this page that we will create the build configuration for this CI project.

We will create the following build configuration steps:

  1. checkout the project from the source repository and update the Ruby gems,
  2. compile the Flex source modules,
  3. restart the webserver, and
  4. run the Cucumber FunFX tests.

First we will create a build step to gather the sources and update any required Ruby Gems. Select the +Create build configuration link. Enter the following in the respective fields of the resulting General Settings screen:

Name: Step 1- Collect Sources
Description: Checkout sources and update gems.
Fail build if: check ‘an error message is logged by build runner’

Leave the remaining fields blank or checked as-is to accept the defaults.

Press the VCS Settings button and enter the following in the respective fields of the resulting Version Control Settings screen:

+Attach existing VCS root: fc_converter-root
VCS checkout mode: Automatically on server
Checkout directory: checkout
VCS labeling mode: Do not label
Choose VCS roots to label: (leave blank- do not check)

The “Automatically on server“ selection will cause the project source to be checked out of the source repository into the TeamCity project working directory.

Press the Choose Build Runner button and enter the following in the respective fields of the resulting Build Runner screen:

Build runner: Rake
Rake tasks: gems:install

Uncheck any Attached reporters that may be checked and leave the remaining fields blank.

Press the Save button to create the build configuration. The screen is refreshed and should show the following message:

Build configuration "Step 1- Collect Sources" has been created successfully.

Select FC Converter Project in the Administration > FC Converter Project > Step 1 ... banner line just under the tabs at the top of the page to return to the main project page. If you named your project differently, your project ‘s name will appear in the banner line.

Next we will create a build step to compile the Flex source modules. Select the +Create build configuration link. Enter the following in the respective fields of the resulting General Settings screen:

Name: Step 2- Flex Compiles
Description: Compile the Flex source modules.
Fail build if: check ‘an error message is logged by build runner’

Leave the remaining fields blank or checked as-is to accept the defaults.

Although we are not checking out the sources in this step (or any subsequent step), we still need to specify the VCS settings to tell TeamCity where the sources are, e.g., in the checkout directory. Press the VCS Settings button and enter the following in the respective fields of the resulting Version Control Settings screen:

+Attach existing VCS root: fc_converter-root
VCS checkout mode: Do not checkout files automatically
Checkout directory: checkout
VCS labeling mode: Do not label
Choose VCS roots to label: (leave blank)

Press the Choose Build Runner button and enter the following in the respective fields of the resulting Build Runner screen:

Build runner: Rake
Rake tasks: flex:compile

Uncheck any Attached reporters that may be checked and leave the remaining fields blank.

Press the Save button to create the build configuration. The screen is refreshed and should show the following message:

Build configuration "Step 2- Flex Compiles" has been created successfully.

Under the right hand column titled Configuration Steps, select 6 Properties and Environment Variables. On the resulting screen, select +Add new variable under Environment Variables. Enter the following in the respective fields of the resulting screen:

Name: FLEX_HOME
Value: /usr/local/flex_4_sdk

and press the Save button.

Again, select FC Converter Project in the Administration > FC Converter Project > Step 1 ... banner line just under the tabs at the top of the page to return to the main project page. If you named your project differently, your project ‘s name will appear in the banner line.

Next we will create a build step to restart the Rails web server. Select the +Create build configuration link. Enter the following in the respective fields of the resulting General Settings screen:

Name: Step 3- Restart the Web Server
Description: Stop and start the Rails web server.
Fail build if: check ‘an error message is logged by build runner’

Leave the remaining fields blank or checked as-is to accept the defaults.

Although we are not checking out the sources in this step we still need to specify the VCS settings to tell TeamCity the sources are in the checkout directory. Press the VCS Settings button and enter the following in the respective fields of the resulting Version Control Settings screen:

+Attach existing VCS root: fc_converter-root
VCS checkout mode: Do not checkout files automatically
Checkout directory: checkout
VCS labeling mode: Do not label
Choose VCS roots to label: (leave blank)

Press the Choose Build Runner button and enter the following in the respective fields of the resulting Build Runner screen:

Build runner: Rake
Rake tasks: webserver:stop webserver:start
Additional Rake command line parameters: RAILS_ENV=cucumber

Uncheck any Attached reporters that may be checked and leave the remaining fields blank.

Press the Save button to create the build configuration. The screen is refreshed and should show the following message:

Build configuration "Step 3- Restart the Web Server" has been created successfully.

Again, select FC Converter Project in the Administration > FC Converter Project > Step 1 ... banner line just under the tabs at the top of the page to return to the main project page. If you named your project differently, your project ‘s name will appear in the banner line.

Finally, we will create a build step to run the Cucumber FunFX tests. Select the +Create build configuration link. Enter the following in the respective fields of the resulting General Settings screen:

 Name: Step 4- Run Cucumber Tests
Description: Run the Cucumber FunFX Tests.
Fail build if: check ‘an error message is logged by build runner’

Leave the remaining fields blank or checked as-is to accept the defaults.

Although we are not checking out the sources in this step we still need to specify the VCS settings to tell TeamCity the sources are in the checkout directory. Press the VCS Settings button and enter the following in the respective fields of the resulting Version Control Settings screen:

 +Attach existing VCS root: fc_converter-root
 VCS checkout mode: Do not checkout files automatically
 Checkout directory: checkout
 VCS labeling mode: Do not label
 Choose VCS roots to label:  (leave blank)

Press the Choose Build Runner button and enter the following in the respective fields of the resulting Build Runner screen:

 Build runner: Rake
 Rake tasks: ci:features

Uncheck any Attached reporters that may be checked and leave the remaining fields blank.

Press the Save button to create the build configuration. The screen is refreshed and should show the following message:

Build configuration "Step 4- Run Cucumber Tests" has been created successfully.

Under the right hand column titled Configuration Steps, select 6 Properties and Environment Variables. On the resulting screen, select +Add new variable under Environment Variables. Enter the following in the respective fields of the resulting screen:

Name:DISPLAY
Value: localhost:1.0

and press the Save button.

Again select +Add new variable under Environment Variables. Enter the following in the respective fields of the resulting screen:

Name:CUCUMBER_FORMAT
Value: progress

and press the Save button.

Select the Projects tab in the top left of the screen to display the build configuration steps for the FC Converter project.


Perform First Build

We’re now ready to execute our first build. We will use the first build configuration step we created to clone the project source for the first time.

To run the first step, press the Run button to the left on the Step 1- Collect Sources line. This will add the step to the build queue and it should begin executing immediately. You should see the 'Running:...' message underneath the step title line within seconds. When the step has completed, 'Running:...' should be replaced with 'Success'.

To view the output of the build step, hover the mouse pointer over the down arrow adjacent to the 'Success' label and select the 'Full log' choice in the resulting drop down menu. Take note of the checkout directory in the log - we will reference this later.

[10:19:14]: Checkout directory: /usr/local/TeamCity/buildAgent/work/fc_converter
[10:19:14]: Updating sources: server side checkout...
[10:19:14]: [Updating sources: server side checkout...] Will perform clean checkout. Reason: Checkout directory is empty or doesn't exist
[10:19:14]: [Updating sources: server side checkout...] Building clean patch for VCS root: fc_converter-root
[10:19:14]: [Updating sources: server side checkout...] Repository sources transferred: 2.59Mb total
[10:19:14]: [Updating sources: server side checkout...] Removing /usr/local/TeamCity/buildAgent/work/fc_converter
[10:19:14]: [Updating sources: server side checkout...] Updating /usr/local/TeamCity/buildAgent/work/fc_converter

This is the directory that contains the source for the FC Converter project. Press the browser's back button to return to the FC Converter project page.

The remaining steps of the build process can be setup to automatically run after successful completion of the immediately previous step. We’ll describe how to do this using the second step as an example. Then you can repeat the process for the third and fourth steps, selecting the appropriate preceding step in each.

Hover the mouse pointer over the down arrow immediately following the title of the second step, Step 2- Flex Compiles, to expose the dropdown menu. Select Edit Settings from the dropdown menu and the General Settings page for the step is displayed.

Select Build Triggering from the list under the Configuration Steps heading on the right margin of the page. We are going to add a build dependency trigger. Select the +Add new trigger link and then select Build Dependency Trigger in the Trigger Type dropdown of the pop-up window. Select Step 1- Collect Sources from the Build Configuration drop down and press Save.

Select the Projects tab at the top of the page to return to the FC Converter project page. Repeat the steps above starting with hovering the mouse pointer for the remaining two steps, selecting the previous step as a build dependency.

When you have finished setting the dependencies, press the Run button in the right margin of the Step 2- Flex Compiles step to launch the remainder of the build process. Each step will execute upon successful completion of the previous step. You can view the results of an individual step by hovering the mouse pointer over the down arrow immediately following the ‘Success’ status label under the step title and selecting either ‘Short log’ or ‘Full log’.

Points of Interest…

Referencing the checkout source directory of the FC Converter project (/usr/local/TeamCity/buildAgent/work/fc_converter)…

In the features/support directory you will notice two files: env.rb and firewatir_firefox_patch.rb. Files in the support directory are loaded by Cucumber prior to running features. The purpose of env.rb is to set up the environment for running features. The purpose of firewatir_firefox_patch.rb is as its name indicates: a patch for the FireWatir::Firefox class. The patch is to support a headless Firefox environment by pre-pending DISPLAY to the command that invokes Firefox.

The features/step_definitions directory contains the fc_converter_steps.rb file which defines the templates for the Cucumber steps used in the features/fc_converter.feature file.

Some things you may want to investigate on your own:

  1. Setting a build trigger for the first step dependent on SCM updates.
  2. Adding more features and Cucumber steps to support them.
  3. Generating some reports from the TeamCity server.
  4. Setting up email notifications on successful and / or failed builds.


Conclusion…

Although our project is a very simple example of using Cucumber, Flex, FunFX, and Firefox, the purpose of this article is to illustrate the setup of the server environment to support a remote, headless, continuous integration environment. And although it’s a little complex, it’s a once-and-done thing. Setting up TeamCity is relatively simple.

Hopefully the log of this journey has helped you in your quest to get Cucumber FunFX tests running in a remote CI environment.

Oh, and if you’re inclined, Chariot Solutions is running a CI event this fall.

In the future, look for a sister post to this one where we’ll use Hudson as our CI server.