srijeda, 19. listopada 2011.

Hudsoning (The Start)

Today it's about Hudson.

Hudson is something called "the continuous integration server". It's used to automatically builds code projects (web applications, mobile applications, whatever) for what-ever-purpose-you-need. So you configure Hudson to build you a project from source code (or source repository).

What is it exactly?

It's basically an WAR file (a Java servlet executable?) you start on any PC that has JRE installed. It attaches it's web interface to a socket on your computer, at the port 8080. You can access it from anywhere using Chrome or a-browser-of-your-choice (avoid IE, it has some font rendering issues) if you know the hostname, so using:

localhost:8080

you connect to the it on your local machine. For example, using

somehostname.somedomain.com:8080 

you get to connect to it from anywhere where there's an Internet connection. If the WAR file or a service is running on that computer, of course. I'll go to the differences later. If you think that's OK :)

A little bit of history with me and Hudson

Running into this tool in my software engineer career was a coincidence. Since I started working for Where Inc. and it's Windows Phone 7 project, some Chinese testers configured a project on Hudson (very badly) to make builds of the app every 5 minutes if there's a change in the SVN repository. It worked good while we used the old repository and the branch naming scheme that was hardcoded in the Ant scripts (which I didn't have access to, so I discovered this when I finally got access). Also using Ant for building a .NET project? You must be joking. 

Next up, I was in charge of the project's technical details (the former software engineer in charge got transferred to a more important project). So as first order of business, I needed to fix the build server, because I changed SVN repositories and project structure. Of course, the build failed to build. And that's NOT OK.

I had a day to get the data of the server, learn Ant scripting, do a lot of RTFM-ing just to figure out what these Chinese folk were doing. Now imagine a turning rainbow wheel....


... after which I got it ready, finally. The general idea was to only hardcode the procedure. Source and destination directories, SVN revision numbers, build paths, changelogs and all other stuff was either given as an external enviroment variable through Hudson or using existing enviroment variables from Hudson. Like SVN version build. Or workspace path. And finally, I was ready to say "And that's OK". But not yet, it seemed to complicate itself.

The Chinese folk also made a small Java console application that modifies the AssemblyInfo.cs file and WMAppManifest.xml file that replaced the minor version and revision numbers with the SVN revision number. AND THAT APP WAS SO VERY MUCH HARDCODED. That most certainly wasn't OK.

Rewrote that small Java console app to use Java properties info file paths, AssemblyInfo.cs and WMAppManifest.xml file pats as command line arguments in precise order. And through Hudson I gave the Ant scripts those file paths which then were used by the Ant script to run the console app and modify those two files. Except the procedure, nothing else wasn't hardcoded. And finally, that was OK.

Branching? Easy. I cloned the Hudson project, changed the SVN repository path to point at the branch, and I got the build.

Migration to Git (TBC)

Interesting stuff happened 6 months after. We migrated to Git, and after transfering the project from SVN to Git, I had to transfer Hudson too. No problem... Really. Except for these two:

  • How to get the project from Github? It used the authentication method with a passphrase, and Hudson didn't have the option to input a user name and password, even after installing the plugin. FAIL.
  • How to get the revision numbers? Git uses hex hash numbers for commit numbers, while SVN uses a simple decimal number. FAIL^2.
I'm afraid I've already taken a lot of time from my working hours to write this so I'm going to stop for a moment. To be continued... to keep you reading more :)

GC.Collect();

Stay tuned for Part Two! I'll put screenshots of the Hudson setup with instructions to make a build of an WP7 Application. WOW, new stuff! 

Is it fun? It is for those who want to know. And that's OK :)

Nema komentara:

Objavi komentar