Howto: Install Jenkins on OS X and make it build Mac stuff

This guide is intended for Lion users. I just tried it on my machine, and it works. Let’s hope it works for you as well.

What’s covered:

  • How to install Jenkins as a standalone Service
  • How to configure a Job that builds a generic Mac-Application
  • Configuring Public Key SSH-Access ( Useful for git )
Prerequisites
  • Java must be installed
  • XCode ( any version that works on Lion will do )
  • You shouldn’t have any services running on port 8080

Installing Jenkins

Jenkins is available as a native package from the Jenkins homepage.  Just install it, as you would install any other package. After you’ve done that, you might want to check if http://localhost:8080/ is reachable. If it’s not, you may have to launch the .war-File by opening it. It’s located in /Applications/Jenkins/.

In case the server is running, you’ll most likely get a 404 ‘not found’ message from the winstone-server that is bundled. If you dig in your syslog, you’ll find a reviling stack trace that indicates that a file can’t be found..

java.io.FileNotFoundException: /Users/Shared/Jenkins/Home/war/META-INF/MANIFEST.MF (No such file or directory)

I don’t know why the package is broken, but it’s quite easy to fix this. I found some great advice on ColonelPanic.net.

First, we’ll create a dedicated jenkins user. At this point, there isn’t one, so just type this into your terminal

sudo dscl . create /Users/jenkins
sudo dscl . create /Users/jenkins PrimaryGroupID 1
sudo dscl . create /Users/jenkins UniqueID 300
sudo dscl . create /Users/jenkins UserShell /bin/bash
sudo dscl . create /Users/jenkins home /Users/Shared/Jenkins/Home/
sudo dscl . create /Users/jenkins NFSHomeDirectory /Users/Shared/Jenkins/Home/
sudo dscl . passwd /Users/jenkins

Now that you have created the user, it’s time to tell the LaunchAgent that came with the install package to use this user to run Jenkins. The file you have to change for this is located at /Library/LaunchDaemons/org.jenkins-ci.plist . Just open it in your favorite editor and change the value of UserName to jenkins.

	<key>UserName</key>
	<string>jenkins</string>

After doing that, the Home folder of jenkins, /Users/Shared/Jenkins/Home needs a new owner.

sudo chown -R jenkins /Users/Shared/Jenkins

After doing all that, saving the modified launch file and chown’ing the Home, unload and reload the service:

sudo launchctl unload -w /Library/LaunchDaemons/org.jenkins-ci.plist
sudo launchctl load -w /Library/LaunchDaemons/org.jenkins-ci.plist

Now you should be greeted by Jenkins if you try again localhost:8080. If not make sure that you followed the steps above correctly. If you did that but it still doesn’t work, please leave a comment.

If you need to access your git repos using a public ssh key, you can generate one now by logging in as the jenkins user and running ssh-keygen

# su jenkins
Password:
bash-3.2$ ssh-keygen
Generating public/private rsa key pair.
Enter file in which to save the key...

You can then upload the file to wherever you need it.

 Create a Job for a XCode Project

Before we dive right in, you need to install the git-plugin. This is done by navigating to “Manage Jenkins” from the welcome screen and then selecting plugins. There are about a million, but you just need git for the moment, as I assume that your project is using git. Once you’ve installed the plugin, set up your git username and email in the “Manage Jerkins” “Configure System” menu. If you omit that step, the source retrieval will fail.

Having setup Jenkins now, it’s time to do some real work. The welcome screen should look similar to the one below, so just go and create a new free-style-software-project. This is the simplest approach possible, but it’s always nice to get results fast… The job configuration screen should show up now, and it’s time to enter some details.

First of all, we need to setup the SCM section, so Jenkins knows where to get the sources from. Just enter your repos git-URL in the appropriate field. To test the whole thing, you can use any git-hosted project you like that homes a XCode-Project.

If you want, you can run a build now to make sure that the git-setup works correctly, but it isn’t required to do so.

As you can see in the screenshot, the next step is creating the build-phase. You can just enter xcodebuild, which will then build your project and Jenkins will notice if it doesn’t work and display it, but I think it’s more interesting to both build a project and archive the App that was built. To achieve that, I created a simple two-line-command

xcodebuild
cd build/Release; zip -r $BUILD_TAG.zip *.app/

Jenkins can archive specific artefacts that were created during the build. To save the generated zip-file just enter the **/*.zip pattern in the “Archive Artefacts” field. If you haven’t built your project yet, there may be a big red warning saying that the filter doesn’t match any files, but it’s safe to ignore it.

Of course, this is the most minimal build setup you could use, but for my purposes it’s completely sufficient. The BUILD_TAG used is a unique tag that can be used for filenames. After you’ve saved the changes to the configuration, it’s time to run a build and see if it works.

There are a lot of ways to go from here, but I hope this tutorial helped you to get Jenkins up and running!

iPad App concept based on a fluid layout

I’m going to discuss briefly a concept idea i had recently, replacing full-screen view controllers with a .. fluid layout. Just look at the video first to get an idea of what I’m talking about. Keep in mind that this is in no way a finished/polished app ( and probably will never be one, considering trademarks and stuff ).

Important note: This app and concept is not affiliated, endorsed or sponsored by ikea. But since it’s non-commercial I hope they won’t shøøt me.

iPad fluid app layout concept from Moritz Haarmann on Vimeo.

So, what’s wrong with the classic view controllers on the iPad? Nothing, absolutely nothing. They are fine. I just wanted to try out this idea, and the video is the result. If you want to test it, leave a comment and I’ll get back to you ( or not ). I guess it is obvious that I’ve been inspired by the Twitter-iPad UI to some extent.

Maybe the most important lesson I learned programming this demo was that it’s really hard to create an interface that acts in accordance with the direct manipulation paradigm.. when there is no real counterpart. I thought about a stack of cards or some other stack model, but none of those resize their content or just “move out” if there is not enough room. I am still not fully convinced that every interaction is right, but at least it feels right most of the time now. If you are curious, there can be an arbitrary number of panels around, of course only limited by memory consumption, without affecting the UI or overall perfomance.

Since I don’t have a phone capable of recording videos right now, you have to believe me that the UI is really snappy on an iPad 2 and yes, it’s even fun to use it.

If you are interested in how I got the data you might want to read a previous post that explained how to retrieve the data from IKEA. Was fun :-)

What do you think? Too confusing? Interesting? Let me know!

Update: If you want to test it locally, please enter your UUID here. No guarantee whatsoever, first come, first serve.

Touch based text input sucks.

I made the experience that an extra-bold title might attract readers. Let’s see. It just occurred to me today that touch based input using software-emulated keyboards with keys and stuff is more stupid than anything else I can think of. Why is that?

Keyboards were invented for typewriters. Typewriters are mechanical machines used by humans to avoid handwriting. Since the first typewriters were invented somewhere around the 18th century, they were rather clumsy, and the machinery used wasn’t really working too well, which is why something as awkward as the QWERTY-layout was invented. The QWERTY-layout, still used today, had its justification in the fact that early typewriters had problems when adjacent keys were used simultaneously, which lead to those keys blocking each other. At this point, in the year 1867, keyboard innovation stalled. No real invention has ever had an effect on any keyboard that is widely used until today. There have been some, like the Dvorak layout, a proposed alternative to the QWERTY-layout, but none of these made it’s way to the mainstream, unfortunately.

Today, we are using beautiful, ultra-turbo-high-speed computers that are still equipped with QWERTY-keyboards. And the nonsense doesn’t stop here, we even shrunk those keyboards down to create digital equivalents. This is just ridiculous. I am in no way doubting that a trained writer can actually write fast using an iPhone, iPad or Android Keyboard, but the reason is certainly not the superior design of those keyboards, but our ability to adapt to even the worst of circumstances.

Of course, numerous attempts have been made to improve the typing experience by adding suggestions, which is done on both Android and iOS, and by invisibly changing the “Hit Box” of each key, which is also done on both platforms. I have done qwerted, which did that highlighting both extremely and visually. There have been similar attempts to do this by Thickbuttons, and maybe some others. IBM recently filed a patent that deals with arranging the keys on a touch keyboard to adapt to a specific user, certainly interesting. But it just masks the fact that this approach is seriously flawed, as it still relies on the basic QWERTY-pattern, instead of something better.

Another approach that has become quite popular lately is the Swype‘s approach. When using Swype ( or SlideIT, and there are certainly a few other similar apps for all systems except stock iOS ), the user just moves over the keys the input consists of. Their homepage has some demo videos if you are curious. Again, the foundation is the old-school QWERTY-keyboard, and even though this concept is highly interesting and working reportedly very well, I consider it broken by design.

The question is: why are we wasting a huge amount of screen real estate displaying keys that won’t ever be typed ( or touched over ) ? Take for example Q and X. Those keys are so rarely used after a word has started, it’s unnecessary that they are displayed by default. But it’s getting better: We can even predict very reliably which words are likely to be typed even after a few words or letters have been typed. If you don’t trust me on this one, you should try Google Scribe. The techniques used here are based on n-grams ( at least a part of it ). N-Grams describe a set of n words, which can then be evaluated in terms of probability. Google has extracted a huge set of n-grams from their datasets which can be obtained at the LDC.

Someone must have come up with a great idea to revolutionize touch input. Like, not some fancy new feature, no, a completely new approach. Do you know Dasher? Something like that, of course massively polished.

I hope you are getting my point here, and I’m sorry I don’t have anything more to offer but a few entry points if you want to read further. This is really interesting field and, if time allows, I’d like to do some work here. What are your ideas?

Fun with nokogiri: Screen-scraping ikea.com

I recently discovered that ikea is really scraping-friendly – they have their categories and products belonging to a category all linked very clean, and the product pages themselves include, as json, the complete product data necessary to display a product somewhere else ( say, on an iPad ). They also feature the assembly instructions linked as pdf and more fun stuff. Just open any product page and browse the source, you will discover a field named “jProductData” which is just what you want.

So i decided it’s time for me to try nokogiri, a beautiful and fast framework for processing urls and searching through the HTML. I managed to write a scraper in only very few lines that actually works. Since the json is embedded in regular JavaScript, i had to use rkelly to parse the javascript part and extract the right data.

For the datamodel, I used ohm with redis, which takes about no time to setup and works as advertised.

If you are curious, the source is available at github.

Fun with CFHTTPMessage, Headers and the HTTP Standard

TL:DR; CFHTTPMessage combines duplicate headers to a single string value containing all headers comma seperated. Thank you.

I am currently developing a Proxy app that visualizes requests and gives you the ability to plug-and-play like filter and modify requests, which makes it a quite powerful tool for debugging web applications, mobile apps and so on.

Of course, this tool is built using Cocoa and Core Foundation. Interesting enough, Core Foundation brings a Type called “CFHTTPMessage”, which handles a lot of low-level message parsing and processing, and is really handy and quite easy to use.

There is one drawback: CFHTTPMessage is not designed to handle both the order in which the headers arrived in a message and duplicate header fields. The first point is somewhat irrelevant, as the HTTP1.1 standard points out that servers are not supposed to depend on any order in the clients – it’s really only a minor issue. The latter point is complicated. HTTP relies on duplicate headers a lot, consider this HTTP request ( Real life!! )


POST /wp-admin/admin-ajax.php HTTP/1.1
X-Requested-With: XMLHttpRequest
Accept-Charset: ISO-8859-1
Accept-Charset: utf-8;q=0.7
Accept-Charset: *;q=0.3
Accept-Encoding: gzip,deflate,sdch
Content-Type: application/x-www-form-urlencoded
Origin: http://momo.brauchtman.net
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_7_0) AppleWebKit/535.1 (KHTML, like Gecko) Chrome/13.0.782.112 Safari/535.1
Cookie: word
Cookie: wordpress_xxxxxxxx
Cookie: wordpress_logged_in_xxxxxx; httponly; expires=Tue
Referer: http://momo.brauchtman.net/wp-admin/post-new.php
Host: momo.brauchtman.net
Accept-Language: de-DE
Accept-Language: de;q=0.8
Accept-Language: en-US;q=0.6
Accept-Language: en;q=0.4
Accept: */*
Content-Length: 1160

There are quite some duplicates here. So the clever guys at Cupertino just forgot to handle duplicate headers at all? No, not really. But they just didn’t document what they are doing with it, which isn’t that clever at all, but fortunately, the sources are available here. So after a bit of digging, I found out that duplicates are simply appended to a former header with same key, which sucks – the delimiter used is a simple comma, which is quite regularly found in header values, which makes splitting an art for itself.

Apples Network Link Conditioner only built for certain CPUs..

Xcode 4.1 comes with a nice tool called Network Link Conditioner, which is basically a GUI to configure certain settings of your network to make it behave like a “Lossy Edge Connection” or something similar. Why would anyone want to do this? In a nutshell, a bunch of bugs in iOS apps are only visible in such environments and hard to catch in office settings with perfect connections. So, to work around that perfect connection, this tool has been invented

Apple-like, it looks great and … doesn’t work ( which is not that Apple-like at all ). At least on my brand-new Early 2011 MBP, it just crashes. So I got curious and ask some friends to double-check it, and bingo, they had similar issues on the comparable i7-equipped machines.

Back at home, I fired the tool on my ancient 2009 iMac, and voila, it works just fine. So.. what the hell is going on there?

[update] I tested the network link conditioner on my new i5-iMac, not a problem there.

Finally, a fine Go Write-Up/Comparison

That is worth linking to just for this highlight

Look at your average web application’s lib directory. I wouldn’t be suprised to see a hundred JAR files there, all just for a simple search database or shopping site which even PHP would do in 10k LOC. And should you be adventurous, try to build it yourself. A world of fun! Setting up a Linux system from scratch, without any step-by-step instructions, is easier. Trust me, I have done both. Be sure you know how to spell “dependency hell” forwards and backwards before you begin.

Here you go: Why all C-like languages except one suck.. ( CC, btw ).

How to pitch bullshit

Most people who know me in person know that I like to talk. A lot. So, I started to do presentations. Some at University, some at School, and some for User Groups and even a bigger one at the JFS Stuttgart. Yet, I always felt that .. well, it was all to serious.

So last friday, while having some drinks with the DevCamp-People, they convinced me to do a not-so-serious presentation. I instantly came up with the topic, hacked the slides in less than 4 hours ( Thanks to Florian! ), and presented them. Never thought that this would fly this much. Pitching Bullshit is running Well on Slideshare, but best of all, an indian blog reports about it. Like :-) .

Android DevCamp 2

Great success last year ( mostly due to almost perfect organization and even better participants ), the second issue of the second largest Android Conference is going to roll just this weekend, called Android Devcamp 2. Unless you are already registered, chances are, you won’t get it.

Unfortunately, I was unable to assist in organizing and planning this year to resource constraints ( Read: too much work ) and a personal decision to throttle back my overall engagement in the whole GTUG Stuttgart. That sucks, but it’s great to see these guys just topping their last years perfomance. Let’s have some nice days in Stuttgart, and maybe a Blinkendroid record?

Diaspora social fu, why it’s too early to be enthusiastic

Hey. It has been some time, but let’s blog again.

Diaspora, the self-claimed privacy aware, personally controlled, do-it-all, open source social network. let’s examine each of those ambitious claims one by one.

Privacy aware. The question here is really: can a network be privacy aware? Is an infrastructure even able to make such promises? As long as this promise is just written, it makes only little sense to me, as privacy is most often not a question of the protocol or idea running a service, but rather of it’s implementation and mostly dependent on its users.

Personally controlled? Facebook is also controlled by it’s users. The problem is actually not control in the net itself, but control towards additional use of your data, e.g. for advertising or some other third party stuff. Again, a protocol or idea won’t be able to change that problem. Just by allowing a net to be just that, there is still a considerable chance of data being accumulated by one provider, like facebook, again. And, as long there is some data concerning you on a database server that is not exclusively administrated by you, your data is not personally controlled.

Do-it-all. I’d rather not comment on that one. But that’s what it is about here. Do-it-all. If it sounds too good to be true, it’s not. Doubtlessly, those smart guys are ambitious and gifted ( at least concerning PR ), but do-it-all is a bit.. over the top. Small steps. Just develop one application, show it, next one. It’s okay and cool and I really appreciate that the protocol can be used for anything, but that also implies complexity. And time.

Open-source. That’s just fine, but at the moment, it’s not. Neither the sources they’re working on, nor the protocol, which is, of course, the more interesting part, are available anywhere. Being a programmer myself, I really understand why the project source is not available at such an early development stage, but it’s crucial for this protocol to become published, even in an early version, as soon as possible.

The protocol, the heart of diaspora, is what invites other people to read and study it. Which may have some desirable consequences: I’d like to build a diaspora node, for example. And I’m pretty sure some other people like to as well. But even more interesting are the ones analyzing it from e.g. a security perspective, commenting on it’s scaling ability or just throwing in new ideas?

Diaspora is fine. I really respect the guys running this project, they are doing a great job, right idea, right time, nothing more powerful. But still, they should really take their time to consider changing some things. Let’s create a google group, let’s share some technical details with the ( really interested ) mass, let’s communicate.